You have jobs with sizes sizes that must be processed in order, packed into batches over days days (one batch per day, consecutive jobs per batch). What's the smallest daily capacity that finishes everything in time?
You can't easily compute it directly, but you can easily check a capacity: greedily pack jobs until the next one won't fit, and count the days. Feasibility is monotonic (bigger capacity → fewer days), so binary search over the capacity.
Implement min_capacity(sizes, days). The answer lies between max(sizes) and sum(sizes). Raise ValueError if days < 1. Your solution should be roughly .
Example: min_capacity([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 5) → 15, with batches [1,2,3,4,5] [6,7] [8] [9] [10].