#C378. Minimum Maximum Reading Time
Minimum Maximum Reading Time
Minimum Maximum Reading Time
You are given an array pages of N positive integers where each element represents the number of pages in a consecutive segment of a book, and an integer M which represents the number of readers. The task is to partition the array into M contiguous segments such that the maximum sum of pages assigned to any reader is minimized.
In other words, if you partition the array into segments S1, S2, \( \dots \), SM, you need to minimize:
[ X = \max_{1 \leq j \leq M} \left(\sum_{i \in S_j} pages_i\right) ]
You can assume that each page count is a positive integer, and a valid partitioning always exists.
inputFormat
The first line contains two space-separated integers: N
(the number of pages) and M
(the number of readers).
The second line contains N
space-separated positive integers representing the pages in each segment.
outputFormat
Output a single integer: the minimized maximum reading time (i.e., the minimum possible maximum sum of pages among all readers).
## sample4 2
10 20 30 40
60