Problem1643--划分数列

1643: 划分数列

Time Limit: 1.000 Sec  Memory Limit: 128 MB
Submit: 9  Solved: 6
[Submit] [Status] [Web Board] [Creator:]

Description

给你一个有n个正整数元素的数列,要求把它划分成k段,使每段元素和的最大值最小


Input

输入第一行两个正整数nk
第二行为此数列ai


Output

输出一行一个数,为题目所求答案


Sample Input

5 2
2 1 3 4 5

Sample Output

9

HINT

30%数据 n <= 30, k <= 10
100%
数据 n <= 100000, k <= n, 0<=ai <= 10^9

Source/Category


[Submit] [Status]