4 0 1 1 1 1 0 1 0 4 6 2 9
16 Consider the following procedure: * First, flip $A_4$. Now, $A = (0, 1, 1, 0)$. The cost of this operation is $0 \times 4 + 1 \times 6 + 1 \times 2 + 0 \times 9 = 8$ yen. * Next, flip $A_2$. Now, $A = (0, 0, 1, 0)$. The cost of this operation is $0 \times 4 + 0 \times 6 + 1 \times 2 + 0 \times 9 = 2$ yen. * Finally, flip $A_1$. Now, $A = (1, 0, 1, 0)$, which matches $B$. The cost of this operation is $1 \times 4 + 0 \times 6 + 1 \times 2 + 0 \times 9 = 6$ yen. In this case, the total cost is $8 + 2 + 6 = 16$ yen, which is the minimum possible.
5 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
0 $A$ and $B$ are already identical initially, so there is no need to perform any operations.
20 1 1 1 1 0 0 1 1 0 0 0 1 0 1 0 1 1 0 1 0 0 0 0 1 1 1 0 1 1 0 0 0 0 0 0 1 0 1 0 0 52 73 97 72 54 15 79 67 13 55 65 22 36 90 84 46 1 2 27 8
2867
{
"problem": {
"name": "Cost to Flip",
"description": {
"content": "You are given two integer sequences of length $N$, $A = (A_1, A_2, \\ldots, A_N)$ and $B = (B_1, B_2, \\ldots, B_N)$, each consisting of $0$ and $1$. You can perform the following operation on $A$ any n",
"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_c"
},
"statements": [
{
"statement_type": "Markdown",
"content": "You are given two integer sequences of length $N$, $A = (A_1, A_2, \\ldots, A_N)$ and $B = (B_1, B_2, \\ldots, B_N)$, each consisting of $0$ and $1$.\nYou can perform the following operation on $A$ any n...",
"is_translate": false,
"language": "English"
}
]
}