#Q15. 「一本通 1.2 练习 1」数列分段 II
「一本通 1.2 练习 1」数列分段 II
Description
Given a sequence of positive integers of length , it is to be divided into segments. Each segment must be continuous, and the maximum sum among all segments should be minimized.
For example, consider the sequence to be divided into segments:
If divided as , the sums of the segments are , and the maximum sum is ;
If divided as , the sums of the segments are , and the maximum sum is ;
Moreover, no matter how the sequence is divided, the maximum sum cannot be less than .
Thus, the minimum possible maximum sum when dividing the sequence into segments is .
Input Format
The first line contains two positive integers and ;
The second line contains non-negative integers separated by spaces, as described in the problem.
Output Format
Output a single positive integer, which is the minimum possible maximum sum among all segments.
Sample 1
5 3
4 2 4 5 1
6
Data Range and Hints
For of the data, ;
For of the data, ;
For of the data, , , and the sum of does not exceed .