Minimized Maximum of Products Distributed to Any Store
Real-world version: Evening Out The Van LoadsThe statement here is our own: the same inputs, outputs and technique.
A sorting hub has couriers vans on the yard tonight and a depot list loads, where loads[i] is the number of parcels waiting at depot i.
Every parcel has to be moved. A van is sent to at most one depot, so everything it carries comes from that single depot, and a van may also be left on the yard carrying nothing. The parcels of a depot may be split between the vans sent to it in any whole numbers you like.
Plan the run so that the heaviest van load is as small as it can be, and return that load.
Examples
Example 1
- Input
- couriers = 6, loads = [11, 6]
- Output
- 3
Send four vans to the first depot carrying 3, 3, 3 and 2 parcels, and two vans to the second carrying 3 each. That is six vans, every parcel is moved, and no van carries more than 3.
Example 2
- Input
- couriers = 3, loads = [10, 1, 1]
- Output
- 10
The two single-parcel depots each need a van of their own, which leaves one van for the depot holding 10, and that van has to take all 10.
Example 3
- Input
- couriers = 4, loads = [6, 2]
- Output
- 2
Three vans take 2 parcels each from the first depot and the fourth van takes both parcels of the second depot, so the heaviest van carries 2.
Constraints
- 1 <= loads.length <= couriers <= 10^5
- 1 <= loads[i] <= 10^5
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 min_largest_van_load(couriers: int, loads: list[int]) -> int:public int minLargestVanLoad(int couriers, int[] loads)Checking your plan…
How this problem was checked
- Passed: Reference solution run against 13 test cases: 13 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
More on the same topics
- Earliest Finish Time for Land and Water Rides IReal-world version: Forge and Kiln BookingEasy
- Longest Subsequence With Limited SumReal-world version: Parcels Within Each AllowanceEasy
- Frequency of the Most Frequent ElementReal-world version: Plates at One ThicknessMedium
- Sell Diminishing-Valued Colored BallsReal-world version: Rare Poster RevenueMedium