Minimum Time to Complete All Deliveries
Real-world version: Two Vans Making Every DropThe statement here is our own: the same inputs, outputs and technique.
Two vans make deliveries. Van i has d[i] drops to make and needs r[i] minutes for each drop it makes.
The two vans work at the same time as each other. Either van may take over any number of the other's drops, so the drops may be shared out between them however you like, but every drop must be made.
Return the fewest minutes until all the drops are done, which is the longer of the two vans' working times.
Examples
Example 1
- Input
- d = [14, 27], r = [5, 3]
- Output
- 78
There are 41 drops between them. In 63 minutes the first van manages 12 and the second 21, which is 33 and not enough; the smallest allowance that covers all 41 is what is returned.
Example 2
- Input
- d = [5, 5], r = [2, 2]
- Output
- 10
Ten drops between two vans of the same speed means five each, at two minutes apiece.
Example 3
- Input
- d = [10, 1], r = [2, 7]
- Output
- 18
Eleven drops in all. The fast van is worth more than three of the slow one's, so it takes most of them, and the two finish together as nearly as whole drops allow.
Constraints
- d.length == 2
- r.length == 2
- 1 <= d[i] <= 10^9
- 2 <= r[i] <= 3 * 10^4
The signature
The editor starts with this. It matches the parent problem's shape, so a solution that works here works on a standard judge unchanged.
def minimum_time(d: list[int], r: list[int]) -> int:public long minimumTime(int[] d, int[] r)Checking your plan…
How this problem was checked
- Passed: Reference solution run against 10 test cases: 10 passed
- Passed: 3 worked examples confirmed by running the code
- Passed: 0 eight-word sequences shared with the parent problem's text
- Passed: Agrees with an independent brute-force solution on random inputs
- Passed: Test set shown to catch deliberately broken solutions
- Passed: Reviewed by a separate quality pass
- Passed: Function arity matches the parent problem's