安徽科技工程大学程序设计在线考试系统Ver3.0
诚信考试,杜绝作弊!
内存限制:512 MB
时间限制:1 S
标准输入输出
题目类型:传统
评测方式:文本比较
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.
1≤ n≤ 100,000
1≤ k≤ 100,000
1≤ wi≤ 10,000