6 3 -1 -4 5 -9 2
8 Starting from the initial state where $S$ is an empty sequence, consider the following operations: * For $i = 1$, append $A_1 = 3$ to the end of $S$. Now, $S = (3)$. * For $i = 2$, append $A_2 = -1$ to the end of $S$. Now, $S = (3, -1)$. * For $i = 3$, delete the last element of $S$. Now, $S = (3)$. * For $i = 4$, append $A_4 = 5$ to the end of $S$. Now, $S = (3, 5)$. * For $i = 5$, append $A_5 = -9$ to the end of $S$. Now, $S = (3, 5, -9)$. * For $i = 6$, delete the last element of $S$. Now, $S = (3, 5)$. Here, the sum of the elements of $S$ after all operations is $3 + 5 = 8$, which is the maximum possible value.
1 -1
\-1 Note that if $S$ is empty, you must choose to append an element.
20 -14 74 -48 38 -51 43 5 37 -39 -29 80 -44 -55 59 17 89 -37 -68 38 -16
369
{
"problem": {
"name": "Operations on a Stack",
"description": {
"content": "You are given an integer sequence of length $N$: $(A_1, A_2, \\ldots, A_N)$. There is also a sequence $S$, which is initially empty. For each $i = 1, 2, \\ldots, N$ in this order, you perform exactly on",
"description_type": "Markdown"
},
"platform": "AtCoder",
"limit": {
"time_limit": 2000,
"memory_limit": 262144
},
"difficulty": "None",
"is_remote": true,
"is_sync": true,
"sync_url": null,
"sign": "arc194_a"
},
"statements": [
{
"statement_type": "Markdown",
"content": "You are given an integer sequence of length $N$: $(A_1, A_2, \\ldots, A_N)$. There is also a sequence $S$, which is initially empty.\nFor each $i = 1, 2, \\ldots, N$ in this order, you perform exactly on...",
"is_translate": false,
"language": "English"
}
]
}