Min Daily Batch Capacity
A pipeline must process an ordered list of job payloads within D days, processing jobs in order and never splitting a job across days. Each day it can process jobs whose total size is at most the worker capacity. Find the minimum capacity that still finishes within D days.
Problem
Given an array sizes (processed in order) and an integer D, return the minimum capacity C such that the jobs can be partitioned into at most D contiguous groups each with sum ≤ C.
Input
An array sizes of length n (1 ≤ n ≤ 10^5), each in [1, 10^4], and an integer D (1 ≤ D ≤ n).
Output
A single integer — the minimum feasible capacity.
Constraints
- 1 ≤ D ≤ n ≤ 100,000
- 1 ≤ sizes[i] ≤ 10,000
- Jobs are processed in the given order and never split
Examples
Example 1
Input
sizes = [1,2,3,4,5,6,7,8,9,10], D = 5
Output
15
With capacity 15 the days are [1..5], [6,7], [8], [9], [10] (5 days). Any capacity below 15 needs more than 5 days.
Example 2
Input
sizes = [3,2,2,4,1,4], D = 3
Output
6
Capacity 6 gives [3,2],[2,4],[1,4] → 3 days. Capacity 5 would need 4 days.