#P10709. [NOISG 2024 Prelim] Party
[NOISG 2024 Prelim] Party
Background
Translated from NOI SG 2024 Prelim B.Party。
Problem Description
James has friends, and he wants to choose or more of them to attend his party. If the -th friend attends his party, it will produce points of happiness. Note: some friends do not want to attend the party, so their will be negative.
However, his home only has a single row of seats, and because of social distancing, two people cannot sit in adjacent seats. Now James wants to know: if he invites friends in the best way, what is the maximum possible sum of happiness values of the invited friends.
Input Format
The first line contains an integer .
The second line contains integers, representing .
Output Format
One line with one integer, representing the answer.
5
3 2 -1 4 5
12
1
10
10
6
1 -3 2 10 -4 9
21
Hint
Sample #1 Explanation
James can invite friends .
Sample #2 Explanation
James can invite the only friend.
Sample #3 Explanation
James can invite friends .
Constraints
| Score | Special Property | |
|---|---|---|
| Samples | ||
| None | ||
For of the testdata, .
Translated by ChatGPT 5