#P1792. [国家集训队] 种树
[国家集训队] 种树
Description
In City A, there is a huge circular plaza. To green the environment and purify the air, the municipal government decided to plant a ring of trees along the outer edge of the circular plaza.
After receiving the order, the parks department initially planned planting positions, numbered clockwise from to . Each position has an aesthetic value , and if a tree is planted there, you gain this value. However, due to poor soil fertility in City A, two trees must not be planted at adjacent positions (positions and are adjacent; note that positions and are also adjacent).
Finally, the municipal government provided the parks department with saplings and requires that all of them be planted. Please design a planting plan to maximize the total aesthetic value. If it is impossible to plant all saplings, output that there is no solution.
Input Format
The first line contains two positive integers .
The second line contains integers, where the -th integer represents .
Output Format
Output one integer, the maximum total aesthetic value achievable by the optimal planting plan. If there is no solution, output Error!.
7 3
1 2 3 4 5 6 7
15
7 4
1 2 3 4 5 6 7
Error!
Hint
| testdata ID | size | testdata ID | size |
|---|---|---|---|
For all testdata: , .
Translated by ChatGPT 5
京公网安备 11011102002149号