5 4 BAAB 3 4 5 5 BBBBB 1 2 3 4 7 BAAABBB 8 7 6 5 4 3 7 BAAABBB 100 7 6 5 4 3 20 BAABAABBBABAAABBBABB 12 85 37 44 25 14 36 29 71 53 15 47 13 80 14 74 53 76 19
3 0 13 15 133 * For the first test case, performing the operation with $i=1$ changes $S$ as `BAAB` → `ABAB`, achieving the goal. The total cost in this case is $x_1=3$. * For the second test case, performing nothing achieves the goal. The total cost in this case is $0$. * For the third test case, performing the operation with $i=1$ and $i=4$ changes $S$ as `BAAABBB` → `ABAABBB` → `ABABABB`, achieving the goal. The total cost in this case is $x_1+x_4=13$. * For the fourth test case, performing the operation with $i=4$, $i=3$, and $i=5$ changes $S$ as `BAAABBB` → `BAABABB` → `BABAABB` → `BABABAB`, achieving the goal. The total cost in this case is $x_4+x_3+x_5=15$.
{
"problem": {
"name": "A Independent Set",
"description": {
"content": "You are given a string $S$ of length $N$ consisting of `A` and `B`. It is guaranteed that the number of `A`s in $S$ is at most $\\frac{N+1}{2}$. Additionally, you are given a sequence of positive integ",
"description_type": "Markdown"
},
"platform": "AtCoder",
"limit": {
"time_limit": 2000,
"memory_limit": 262144
},
"difficulty": "None",
"is_remote": true,
"is_sync": true,
"sync_url": null,
"sign": "agc066_d"
},
"statements": [
{
"statement_type": "Markdown",
"content": "You are given a string $S$ of length $N$ consisting of `A` and `B`. It is guaranteed that the number of `A`s in $S$ is at most $\\frac{N+1}{2}$. Additionally, you are given a sequence of positive integ...",
"is_translate": false,
"language": "English"
}
]
}