#Q179. 「一本通 5.5 例 3」修剪草坪
「一本通 5.5 例 3」修剪草坪
Description
Original Source: USACO 2011 Open Gold
After winning the town's best lawn competition a year ago, FJ became lazy and has not mowed the lawn since. Now, a new round of the best lawn competition has begun, and FJ hopes to win the championship again.
However, FJ's lawn is very messy, so he can only rely on his cows to do the job. FJ has cows lined up in a row, numbered from to . Each cow has a different efficiency, with cow having an efficiency of .
Cows that are close to each other are familiar. If FJ assigns more than consecutive cows, these cows will go on strike and throw a party. Therefore, FJ now needs your help to calculate the maximum efficiency he can obtain without selecting more than consecutive cows in any arrangement.
Input Format
The first line contains two space-separated integers and ;
The second to the -th lines each contain an integer .
Output Format
A single line with the maximum efficiency value FJ can obtain.
Sample 1
FJ has cows with efficiencies . He wants to select the cows with the maximum total efficiency but cannot choose more than consecutive cows. FJ selects all cows except the third one, resulting in a total efficiency of .
5 2
1
2
3
4
5
12
Constraints & Hints
For all data, .