/ OPS / 题库 /

Mowing the Lawn

Mowing the Lawn

#描述#
After winning the annual town competition for best lawn a year ago,
Farmer John has grown lazy; he has not mowed the lawn since then
and thus his lawn has become unruly. However, the competition is
once again coming soon, and FJ would like to get his lawn into
tiptop shape so that he can claim the title.
<BR>
<BR>
Unfortunately, FJ has realized that his lawn is so unkempt that he
will need to get some of his N (1 <= N <= 100,000) cows, who are
lined up in a row and conveniently numbered 1..N, to help him. Some
cows are more efficient than others at mowing the lawn; cow i has
efficiency E_i (0 <= E_i <= 1,000,000,000).
<BR>
<BR>
FJ has noticed that cows near each other in line often know each
other well; he has also discovered that if he chooses more than K
(1 <= K <= N) consecutive (adjacent) cows to help him, they will
ignore the lawn and start a party instead. Thus, FJ needs you to
assist him: determine the largest total cow efficiency FJ can obtain
without choosing more than K consecutive cows.

#格式#
##输入格式##
(multi testcase).
Line 1: Two space-separated integers: N and K.

Lines 2..N+1: Line i+1 contains the single integer: E_i

##输出格式##
A single integer that is the best total efficiency FJ can
obtain.

#样例1#
##样例输入1##

5 2
1
2
3
4
5

##样例输出1##

12

#限制#
1000ms
32768KB

#提示#
FJ chooses all cows but the third. The total efficiency of the cows is thus
1 + 2 + 4 + 5 = 12.

#来源#

信息

ID
1853
难度
5
分类
category1 点击显示
标签
递交数
0
已通过
0
通过率
?
上传者