atcoder#AGC050B. [AGC050B] Three Coins
[AGC050B] Three Coins
Score : points
Problem Statement
cells are arranged in a row. The cells are numbered through from left to right.
Initially, all cells are empty. You can perform the following two types of operation arbitrary number of times in arbitrary order:
- Choose three consecutive empty cells, and put a coin on each of the three cells.
- Choose three consecutive cells with coins, and remove all three coins on the chosen cells.
After you finish performing operations, if the -th cell contains a coin, you get points. Your score is the sum of all points you get from the cells with coins.
Compute the maximum possible score you can earn.
Constraints
- All values in the input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the answer.
4
1
2
3
4
9
We represent a cell with a coin as o
and a cell without a coin as .
(a dot).
One optimal way is as follows:
....
.ooo
We get points this way.
6
3
-2
-1
0
-1
4
6
One optimal way is as follows:
......
ooo...
oooooo
o...oo
We get points this way.
10
-84
-60
-41
-100
8
-8
-52
-62
-61
-76
0