2120: 划分数列

Memory Limit:128 MB Time Limit:1.000 S
Judge Style:Text Compare Creator:
Submit:1 Solved:1

Description

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

Input

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

Output

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

Sample Input Copy

5 2
2 1 3 4 5

Sample Output Copy

9

HINT

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

Source/Category