Loading...
Loading...
Loading...
Parcels must be delivered in the given order. Each day a truck takes a run of parcels whose total weight is at most its capacity. Print the smallest capacity that delivers all parcels within the given number of days.
Example
Input
6 3 4 8 3 9 5 2
Output
12
Try the problem first. Open one hint at a time.
A truck cannot be lighter than the heaviest parcel, and a truck as big as the total always works in one day.
For a capacity, count the days greedily: start a new day when the next parcel does not fit. More capacity never needs more days.
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor