Hide

Problem G
Milk Mystery

Megatron, a mischievous orange kitten, has discovered $N$ bowls of milk in the kitchen. Being a very picky cat, he has developed a sophisticated rating system for milk - each bowl has a "deliciousness score" that represents how tasty he thinks it will be. The problem is, Megatron’s human has caught on to his milk-stealing habits and installed a security system. The system will only let Megatron drink from exactly $K$ consecutive bowls before it activates. Megatron needs to figure out which sequence of $K$ consecutive bowls will give him the maximum total deliciousness before the alarm goes off!

Input

The first line contains two integers $N$ and $K$, where $N$ is the total number of milk bowls and $K$ is how many consecutive bowls Megatron can drink from. The second line contains $N$ integers $d_1, d_2, \ldots , d_N$, where $d_i$ represents the deliciousness score that Megatron assigns to the $i$th bowl of milk.

Output

Output a single integer - the maximum sum of deliciousness scores that Megatron can achieve by drinking from $K$ consecutive bowls.

Limits

  • $1 \leq K \leq N \leq 100$

  • $0 \leq d_i \leq 100$

Sample Input 1 Sample Output 1
5 2
1 3 2 5 1
7
Sample Input 2 Sample Output 2
4 3
2 2 2 2
6

Please log in to submit a solution to this problem

Log in