문제
For his favorite holiday, Farmer John wants to send presents to his friends. Since he isn't very good at wrapping presents, he wants to enlist the help of his cows. As you might expect, cows are not much better at wrapping presents themselves, a lesson Farmer John is about to learn the hard way.
Farmer John's
Please help FJ determine the highest possible sum of skill levels he can achieve by optimally forming teams.
Problem credits: Brian Dean
입력
The first line of input contains
출력
Please print the highest possible sum of skill levels FJ can achieve by grouping appropriate consecutive sets of cows into teams.
예제
7 3
1
15
7
9
2
5
10
84
In this example, the optimal solution is to group the first three cows and the last three cows, leaving the middle cow on a team by itself (remember that it is fine to have teams of size less than