3 4 2 1 2 3 1 4 3 0
2 6 Consider the first query. We replace the value of $A_1$ with $4$, making $A=(4,2,3)$. Then, the value of $f(A)$ is calculated as follows: * Prepare $y=(0,0,0,0)$. * Perform the operation for $A_1=4$, resulting in $y=(0,0,0,0)$. * Perform the operation for $A_2=2$, resulting in $y=(0,0,1,1)$. * Perform the operation for $A_3=3$, resulting in $y=(0,0,0,2)$. * The sum of the elements of $y$, which equals $2$, is the value of $f(A)$. Next, consider the second query. We replace the value of $A_3$ with $0$, making $A=(4,2,0)$. Then, the value of $f(A)$ is calculated as follows: * Prepare $y=(0,0,0,0)$. * Perform the operation for $A_1=4$, resulting in $y=(0,0,0,0)$. * Perform the operation for $A_2=2$, resulting in $y=(0,0,1,1)$. * Perform the operation for $A_3=0$, resulting in $y=(1,1,2,2)$. * The sum of the elements of $y$, which equals $6$, is the value of $f(A)$.
7 2 9 2 0 2 2 0 1 0 1 1 3 0 4 0 4 1 6 1 3 2 2 0 3 2 2 0
4 7 11 9 9 6 6 6 6
20 200000 10 39664 143179 193565 153887 16141 91985 51452 155409 116777 190060 87620 64458 106481 51272 9108 100995 139248 18243 181424 6182 4 196305 13 59753 8 96194 6 57037 19 125781 16 142779 15 13967 10 17772 16 84763 12 17283
1145670 1234421 1352851 1352851 1464137 1380569 1380569 1608611 1724643 1736769
{
"problem": {
"name": "Up-Down Queries",
"description": {
"content": "For an integer sequence $x=(x_1,x_2,\\cdots,x_N)$ of length $N$ with each element being between $0$ and $M$, inclusive, we define $f(x)$ as follows: * Prepare an integer sequence $y=(y_1,y_2,\\cdots,",
"description_type": "Markdown"
},
"platform": "AtCoder",
"limit": {
"time_limit": 5000,
"memory_limit": 262144
},
"difficulty": "None",
"is_remote": true,
"is_sync": true,
"sync_url": null,
"sign": "arc168_f"
},
"statements": [
{
"statement_type": "Markdown",
"content": "For an integer sequence $x=(x_1,x_2,\\cdots,x_N)$ of length $N$ with each element being between $0$ and $M$, inclusive, we define $f(x)$ as follows:\n\n* Prepare an integer sequence $y=(y_1,y_2,\\cdots,...",
"is_translate": false,
"language": "English"
}
]
}