Peanut is playing a card game today, and in this card game, Bradley deals him a set of N cards in a row and lays them in a row from left to right. Each of this card contains an integer, which can be positive or negative. Bradley then asks Peanut to select up to K non-overlapping ranges of length up to L. He then has to pick up those cards and sum them. Help Peanut find the maximum sum.
The first line of input contains three integers, N, K and L.
The second line of input contains N integers, which represent the cards given to Peanut by Bradley.
Your program should output one integer, stating the maximum sum Peanut can obtain.
7 1 7 5 -9 3 -2 5 5 -3
11
5 -9 (3 -2 5 5) -3
10 3 3 1 -2 3 4 8 -6 7 -8 9 -10
31
1 -2 (3 4 8) -6 (7) -8 (9) -10
Subtask | Score |
---|---|
1 | 3 |
2 | 11 |
3 | 14 |
4 | 25 |
5 | 47 |
6 | 0 |