{"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 number of times (possibly zero):\n\n1.  First, choose an integer $i$ satisfying $1 \\leq i \\leq N$, and flip the value of $A_i$ (if the original value is $0$, change it to $1$; if it is $1$, change it to $0$).\n2.  Then, pay $\\sum_{k=1}^N A_k C_k$ yen as the cost of this operation.\n\nNote that the cost calculation in step 2 uses the $A$ after the change in step 1.\nPrint the minimum total cost required to make $A$ identical to $B$.\n\n## Constraints\n\n*   $1 \\leq N \\leq 2 \\times 10^5$\n*   $A_i, B_i \\in {0, 1}$\n*   $1 \\leq C_i \\leq 10^6$\n*   All input values are integers.\n\n## Input\n\nThe input is given from Standard Input in the following format:\n\n$N$\n$A_1$ $A_2$ $\\ldots$ $A_N$\n$B_1$ $B_2$ $\\ldots$ $B_N$\n$C_1$ $C_2$ $\\ldots$ $C_N$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"arc194_c","tags":[],"sample_group":[["4\n0 1 1 1\n1 0 1 0\n4 6 2 9","16\n\nConsider the following procedure:\n\n*   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.\n*   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.\n*   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.\n\nIn this case, the total cost is $8 + 2 + 6 = 16$ yen, which is the minimum possible."],["5\n1 1 1 1 1\n1 1 1 1 1\n1 1 1 1 1","0\n\n$A$ and $B$ are already identical initially, so there is no need to perform any operations."],["20\n1 1 1 1 0 0 1 1 0 0 0 1 0 1 0 1 1 0 1 0\n0 0 0 1 1 1 0 1 1 0 0 0 0 0 0 1 0 1 0 0\n52 73 97 72 54 15 79 67 13 55 65 22 36 90 84 46 1 2 27 8","2867"]],"created_at":"2026-03-03 11:01:14"}}