|시간 제한||메모리 제한||제출||정답||맞은 사람||정답 비율|
|2 초||512 MB||5||5||5||100.000%|
You are participating in the Association for Computing Machinery’s Intercollegiate Programming Competition (ACM ICPC). You must complete a set of n problems. Since you are an experienced problem solver, you can read a problem and accurately estimate how long it will take to solve it, in a negligible amount of time. But you can only keep the details from k problems straight at any given time.
Let ti be the time it will take to solve the ith problem. Your strategy for the contest is as follows:
You want to calculate your total penalty time for the contest. Your penalty time for the contest is defined by the sum of submission times for all the problems. Given the ordering of problems in the contest, compute the penalty time of your strategy.
The first line of input contains two space-separated integers n and k (1 ≤ k ≤ n ≤ 300).
The ith line of the next n lines contains a single integer ti (1 ≤ ti ≤ 1,000,000).
Print, on a single line, a single integer repesenting the total penalty time.
4 3 1 3 2 1