Binary search on the answer · shipping capacity

What is the smallest capacity that ships every parcel within the allowed days? The order is fixed.

The heaviest parcel sets the lower bound. The sum of all weights sets the upper bound: that capacity can carry everything in one day.

Test the midpoint. Load parcels in order until the next one would exceed capacity, then start a new day. Filling each day as far as possible uses the fewest days at that capacity.

If a capacity works, every larger one works. If it fails, smaller ones fail too. Each test scans all n parcels and the search halves the range.