Problem B: Search - Allocation

"
Time Limit $1$ 秒/Second(s) Memory Limit $512$ 兆字节/Megabyte(s)
提交总数 $107$ 正确数量 $40$
裁判形式 标准裁判/Standard Judge 我的状态 尚未尝试
难度 分类标签 STL 二分答案 二分
You are given n packages of wi kg from a belt conveyor in order (i=0,1,...n−1). You should load all packages onto k trucks which have the common maximum load PP. Each truck can load consecutive packages (more than or equals to zero) from the belt conveyor unless the total weights of the packages in the sequence does not exceed the maximum load P. Write a program which reads n, k and wi, and reports the minimum value of the maximum load PP to load all packages from the belt conveyor.
In the first line, two integers n and k are given separated by a space character. In the following n lines, wi are given respectively.
Print the minimum value of P in a line.
5 3
8
1
7
3
9
10

1≤ n≤ 100,000

1≤ k≤ 100,000 

1≤ wi≤ 10,000