Problem Statement | |||||||||||||
You have to load a ship with some cargo. All the cargo is put in boxes. There are some cranes and each of them can put one box in the ship per minute. All cranes can work simultaneously. Each crane has a weight limit - it cannot move a box whose weight is greater than that limit. Return the minimal time (measured in minutes) needed to load the ship with all cargo or -1 if it is impossible. You are given a int[] cranes, the i-th element of which is the weight limit of the i-th crane. You are also given a String[] boxes. Concatenate the elements of boxes to get a space-separated list of the boxes' weights. | |||||||||||||
Definition | |||||||||||||
| |||||||||||||
Constraints | |||||||||||||
- | cranes will contain between 1 and 50 elements, inclusive. | ||||||||||||
- | boxes will contain between 1 and 50 elements, inclusive. | ||||||||||||
- | Each element of boxes will contain between 0 and 50 characters, inclusive. | ||||||||||||
- | The concatenation of all elements of boxes will be a non-empty space-separated list of integers with no leading zeroes. It will contain no leading, trailing, or consecutive spaces. | ||||||||||||
- | Each element of cranes will be between 1 and 1,000,000, inclusive. | ||||||||||||
- | Each box weight will be between 1 and 1,000,000, inclusive. | ||||||||||||
Examples | |||||||||||||
0) | |||||||||||||
| |||||||||||||
1) | |||||||||||||
| |||||||||||||
2) | |||||||||||||
| |||||||||||||
3) | |||||||||||||
| |||||||||||||
4) | |||||||||||||
|