#P1182. 数列分段 Section II
数列分段 Section II
Description
Given a sequence of positive integers of length , you need to partition it into () contiguous segments, such that the maximum segment sum is minimized.
About minimizing the maximum:
For example, consider the sequence to be divided into segments.
Partition it as:
The sum of the first segment is , the sum of the second segment is , the sum of the third segment is , and the maximum of these sums is .
Partition it as:
The sum of the first segment is , the sum of the second segment is , the sum of the third segment is , and the maximum of these sums is .
Moreover, no matter how you partition it, the maximum will not be smaller than .
Therefore, for the sequence divided into segments, the minimum possible maximum segment sum is .
Input Format
The first line contains two positive integers .
The second line contains space-separated non-negative integers , as described above.
Output Format
A single positive integer: the minimum possible value of the maximum segment sum.
5 3
4 2 4 5 1
6
Hint
Constraints:
- For of the testdata, .
- For of the testdata, .
- For of the testdata, , , , and the answer does not exceed .
Translated by ChatGPT 5
京公网安备 11011102002149号