#P2627. [USACO11OPEN] Mowing the Lawn G
[USACO11OPEN] Mowing the Lawn G
Description
After winning the town’s Best Lawn contest a year ago, Farmer John became lazy and hasn’t mowed the lawn since. Now, a new Best Lawn contest is starting, and Farmer John hopes to win again.
However, Farmer John’s lawn is a mess, so he can only rely on his cows to do the job. Farmer John has () cows in a row, numbered . Each cow has a different efficiency; cow has efficiency ().
Neighboring cows are very familiar with each other, so if Farmer John schedules more than () consecutive cows, they will go on strike to throw a party :). Therefore, Farmer John needs your help to compute the maximum total efficiency he can obtain, with no stretch of more than consecutive cows.
Input Format
The first line contains two integers and separated by a space.
The second to -th lines: the -th line contains an integer .
Output Format
Output a single value: the maximum total efficiency that Farmer John can obtain.
5 2
1
2
3
4
5
12
Hint
Translated by ChatGPT 5
京公网安备 11011102002149号