#P1484. 种树
种树
Description
cyrcyr is planting trees today. He dug pits on a straight line. Each of these pits can be used to plant a tree, but to ensure every tree has sufficient nutrients, cyrcyr will not plant trees in two adjacent pits. Also, because cyrcyr does not have enough saplings, he will plant at most trees. Assuming cyrcyr has a special ability to foresee the profit from planting a tree in any pit (which may be negative), please help him compute his maximum total profit.
Input Format
The first line contains two positive integers .
The second line contains integers. The -th number denotes the profit from planting a tree in the -th pit from left to right on the line.
Output Format
Output a single number, the maximum profit that cyrcyr can obtain.
6 3
100 1 -1 100 1 -1
200
Hint
For of the testdata, .
For of the testdata, .
For of the testdata, , , and the absolute value of the profit at any single position is at most .
Translated by ChatGPT 5
京公网安备 11011102002149号