#C316. Minimized Maximum Task Time Assignment
Minimized Maximum Task Time Assignment
Minimized Maximum Task Time Assignment
You are given a list of task times and a number of team members \(k\). Your task is to partition the list of tasks into \(k\) contiguous segments such that the maximum total time assigned to any team member is minimized.
More formally, given an array \(T = [t_1, t_2, \dots, t_n]\) and an integer \(k\), you need to determine the minimum possible value \(M\) such that there exists a partition of \(T\) into \(k\) (or fewer) contiguous segments where the sum of each segment is at most \(M\).
You can solve this problem using a binary search technique combined with a greedy checking function. The search range is from \(\max(T)\) (because each segment must contain at least one task) to \(\sum_{i=1}^{n}t_i\). In each step, check if it is possible to partition the tasks under the current maximum allowed value.
Note: The tasks must be assigned in the order given (i.e., the segments are contiguous).
inputFormat
The input is given from stdin and consists of two lines. The first line contains two space-separated integers \(n\) and \(k\) (the number of tasks and the number of team members, respectively). The second line contains \(n\) space-separated integers representing the times of the tasks.
\(1 \leq n \leq 10^5\), \(1 \leq k \leq n\), and each task time is a positive integer.
outputFormat
Output the minimized maximum task time (an integer) to stdout.
## sample5 2
10 20 30 40 50
90
</p>