AtCoder Grand Contest 050 (Good Bye rng_58 Day 1)
翻译中…
Problem Statement
翻译中…
$N$ cells are arranged in a row. The cells are numbered $1$ through $N$ 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 $i$-th cell contains a coin, you get $a_i$ 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
翻译中…
$3 \leq N \leq 500$$-100 \leq a_i \leq 100$- All values in the input are integers.
翻译中…
Input
翻译中…
Input is given from Standard Input in the following format:
翻译中…
N
a_1
a_2
:
a_N
翻译中…
Output
翻译中…
Print the answer.
翻译中…
样例
Input #1
4
1
2
3
4
Output #1
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:
`....` $\rightarrow$ `.ooo`
We get $2 + 3 + 4 = 9$ points this way.
Input #2
6
3
-2
-1
0
-1
4
Output #2
6
One optimal way is as follows:
`......` $\rightarrow$ `ooo...` $\rightarrow$ `oooooo` $\rightarrow$ `o...oo`
We get $3 + (-1) + 4 = 6$ points this way.
Input #3
10
-84
-60
-41
-100
8
-8
-52
-62
-61
-76
Output #3
0
题目信息
题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。