AtCoder Grand Contest 008
翻译中…
Problem Statement
翻译中…
There are $N$ squares aligned in a row. The $i$-th square from the left contains an integer $a_i$.
翻译中…
Initially, all the squares are white. Snuke will perform the following operation some number of times:
翻译中…
- Select
$K$consecutive squares. Then, paint all of them white, or paint all of them black. Here, the colors of the squares are overwritten.
翻译中…
After Snuke finishes performing the operation, the score will be calculated as the sum of the integers contained in the black squares. Find the maximum possible score.
翻译中…
Constraints
翻译中…
$1≤N≤10^5$$1≤K≤N$$a_i$is an integer.$|a_i|≤10^9$
翻译中…
Input
翻译中…
The input is given from Standard Input in the following format:
翻译中…
N K
a_1 a_2 ... a_N
翻译中…
Output
翻译中…
Print the maximum possible score.
翻译中…
样例
Input #1
5 3
-10 10 -10 10 -10
Output #1
10
Paint the following squares black: the second, third and fourth squares from the left.
Input #2
4 2
10 -10 -10 10
Output #2
20
One possible way to obtain the maximum score is as follows:
- Paint the following squares black: the first and second squares from the left.
- Paint the following squares black: the third and fourth squares from the left.
- Paint the following squares white: the second and third squares from the left.
Input #3
1 1
-10
Output #3
0
Input #4
10 5
5 -4 -5 -8 -4 7 2 -4 0 7
Output #4
17
题目信息
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。