P26612 [AtCoder] Neutralize
普及+
题目描述

Problem Description

There are $ N $ chemicals arranged in a row. Each chemical has an integer value called utility, and the current utility of the $ i $-th chemical from the left is $ b_i $. These values are not necessarily positive.

Kenkoooo can perform the following operation any number of times (or none) using a special long device:

  • Select $ K $ consecutive chemicals. The utility of all selected chemicals becomes $ 0 $.

Note that it is dangerous to move the chemicals, so it is not allowed.

Afterwards, Kenkoooo will drink all $ N $ chemicals. Before doing so, he wants to maximize the sum of the utilities of the $ N $ chemicals. Find the maximum possible sum of the utilities after the operations.

Input Format

The input is given from the standard input in the following format:

$ N $ $ K $ $ b_1 $ $ : $ $ b_N $

Output Format

Output the maximum sum of the utilities of the $ N $ chemicals after the operations.

Sample Input and Output

Sample Input #1

9 3
-1
-2
-3
4
5
-6
-7
-8
-9

Sample Output #1

9

Sample Input #2

5 4
-1
-1
5
-1
-1

Sample Output #2

1

Sample Input #3

9 5
30
-20
40
60
-90
50
-40
10
70

Sample Output #3

120

Sample Input #4

10 1
1000000000
-1000000000
1000000000
-1000000000
1000000000
-1000000000
1000000000
-1000000000
1000000000
-1000000000

Sample Output #4

5000000000

Notes/Hints

Constraints

  • $1\ \leq\ K\ \leq\ N\ \leq\ 2\ \times\ 10^5$
  • $-10^9\ \leq\ b_i\ \leq\ 10^9$
  • All values in the input are integers.

Sample Explanation 1

An example of the optimal procedure:
- First operation: Select the chemicals from the 1st to the 3rd from the left.
- Second operation: Select the chemicals from the 6th to the 8th from the left.
- Third operation: Select the chemicals from the 7th to the 9th from the left.
At this point, the sum of the utilities of the 9 chemicals is $0\ +\ 0\ +\ 0\ +\ 4\ +\ 5\ +\ 0\ +\ 0\ +\ 0\ +\ 0\ =\ 9$.

Sample Explanation 2

It is best to drink the chemicals as they are without any operations.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
9 3 -1 -2 -3 4 5 -6 -7 -8 -9
样例输出
9