7 2 1 1 3 5 3 3
3
The operations proceed as follows:
* After the first operation, the sequence has one ball, of size $2^2$.
* After the second operation, the sequence has two balls, of sizes $2^2$ and $2^1$ in order.
* After the third operation, the sequence has one ball, of size $2^3$. This is obtained as follows:
* When the third ball is added during the third operation, the sequence has balls of sizes $2^2, 2^1, 2^1$ in order.
* The first and second balls from the right have the same size, so these balls are removed, and a ball of size $2^1 + 2^1 = 2^2$ is added. Now, the sequence has balls of sizes $2^2, 2^2$.
* Again, the first and second balls from the right have the same size, so these balls are removed, and a ball of size $2^2 + 2^2 = 2^3$ is added, leaving the sequence with a ball of size $2^3$.
* After the fourth operation, the sequence has one ball, of size $2^4$.
* After the fifth operation, the sequence has two balls, of sizes $2^4$ and $2^5$ in order.
* After the sixth operation, the sequence has three balls, of sizes $2^4$, $2^5$, $2^3$ in order.
* After the seventh operation, the sequence has three balls, of sizes $2^4$, $2^5$, $2^4$ in order.
Therefore, you should print $3$, the final number of balls in the sequence.5 0 0 0 1 2
4 The operations proceed as follows: * After the first operation, the sequence has one ball, of size $2^0$. * After the second operation, the sequence has one ball, of size $2^1$. * After the third operation, the sequence has two balls, of sizes $2^1$ and $2^0$ in order. * After the fourth operation, the sequence has three balls, of sizes $2^1$, $2^0$, $2^1$ in order. * After the fifth operation, the sequence has four balls, of sizes $2^1$, $2^0$, $2^1$, $2^2$ in order. Therefore, you should print $4$, the final number of balls in the sequence.
{
"problem": {
"name": "Merge the balls",
"description": {
"content": "You have an empty sequence and $N$ balls. The size of the $i$\\-th ball $(1 \\leq i \\leq N)$ is $2^{A_i}$. You will perform $N$ operations. In the $i$\\-th operation, you add the $i$\\-th ball to the ri",
"description_type": "Markdown"
},
"platform": "AtCoder",
"limit": {
"time_limit": 2000,
"memory_limit": 262144
},
"difficulty": "None",
"is_remote": true,
"is_sync": true,
"sync_url": null,
"sign": "abc351_c"
},
"statements": [
{
"statement_type": "Markdown",
"content": "You have an empty sequence and $N$ balls. The size of the $i$\\-th ball $(1 \\leq i \\leq N)$ is $2^{A_i}$.\nYou will perform $N$ operations. \nIn the $i$\\-th operation, you add the $i$\\-th ball to the ri...",
"is_translate": false,
"language": "English"
}
]
}