安徽科技工程大学程序设计在线考试系统Ver3.0

诚信考试,杜绝作弊!

问题 E: 4_D : Allocation

内存限制: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.

输入样例 复制

5 3
8
1
7
3
9

输出样例 复制

10

数据范围与提示

1≤ n≤ 100,000

1≤ k≤ 100,000 

1≤ wi≤ 10,000