cx has a chain of $N$ diamonds, each of value $a_i$. She wishes to detach some diamonds in the chain, and keep $k$ consecutive diamond chains for herself. In addition, she wants to maximise the total sum of all diamonds' values in his $k$ chains. Can you help her to determine the maximum of such value?
Note that a final diamond chain can have zero length.
Input
The first line of input contains two integers, $N$ and $k$. The second line contains $N$ integers, $a_i$, the values of the diamonds.
Output
Output a single integer, the maximum sum of values of the diamonds in the chains.
Constraints
For all testcases:
$1 \le N \le 10^4$
$1 \le k \le 100$
$-10^9 \le a_i \le 10^9$
Sample Test Cases
| Input | Output | |
|---|---|---|
| 10 3 5 -4 2 9 -1 3 -10 3 -8 6 |
||
We keep the chains [5], [2, 9, -1, 3], and [6], achieving a sum of 24. |
||
Scoring: Per Case
Authored by s17f18
Appeared in 2025 Mini Comp 3