{"problem":{"name":"Gomamayo Sequence","description":{"content":"You are given a string $S$ of length $N$ consisting of `0` and `1`. A string $T$ of length $N$ consisting of `0` and `1` is a **good string** if and only if it satisfies the following condition: *   ","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"abc346_d"},"statements":[{"statement_type":"Markdown","content":"You are given a string $S$ of length $N$ consisting of `0` and `1`.\nA string $T$ of length $N$ consisting of `0` and `1` is a **good string** if and only if it satisfies the following condition:\n\n*   There is exactly one integer $i$ such that $1 \\leq i \\leq N - 1$ and the $i$\\-th and $(i + 1)$\\-th characters of $T$ are the same.\n\nFor each $i = 1,2,\\ldots, N$, you can choose whether or not to perform the following operation once:\n\n*   If the $i$\\-th character of $S$ is `0`, replace it with `1`, and vice versa. The cost of this operation, if performed, is $C_i$.\n\nFind the minimum total cost required to make $S$ a good string.\n\n## Constraints\n\n*   $2 \\leq N \\leq 2 \\times 10^5$\n*   $S$ is a string of length $N$ consisting of `0` and `1`.\n*   $1 \\leq C_i \\leq 10^9$\n*   $N$ and $C_i$ are integers.\n\n## Input\n\nThe input is given from Standard Input in the following format:\n\n$N$\n$S$\n$C_1$ $C_2$ $\\ldots$ $C_N$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"abc346_d","tags":[],"sample_group":[["5\n00011\n3 9 2 6 4","7\n\nPerforming the operation for $i = 1, 5$ and not performing it for $i = 2, 3, 4$ makes $S =$ `10010`, which is a good string. The cost incurred in this case is $7$, and it is impossible to make $S$ a good string for less than $7$, so print $7$."],["4\n1001\n1 2 3 4","0"],["11\n11111100111\n512298012 821282085 543342199 868532399 690830957 973970164 928915367 954764623 923012648 540375785 925723427","2286846953"]],"created_at":"2026-03-03 11:01:14"}}