Preparando MOJI
Berland State University (BSU) is conducting a programming boot camp. The boot camp will last for $$$n$$$ days, and the BSU lecturers are planning to give some number of lectures during these days.
Some days of the boot camp are already planned as excursion days, and no lectures should be held during these days. To make sure the participants don't get too tired of learning to program, the number of lectures for each day should not exceed $$$k_1$$$, and the number of lectures for each pair of consecutive days should not exceed $$$k_2$$$.
Can you calculate the maximum number of lectures that can be conducted during the boot camp? Formally, find the maximum integer $$$m$$$ such that it is possible to choose $$$n$$$ non-negative integers $$$c_1$$$, $$$c_2$$$, ..., $$$c_n$$$ (where $$$c_i$$$ is the number of lectures held during day $$$i$$$) so that:
Note that there might be some non-excursion days without lectures (i. e., it is possible that $$$c_i = 0$$$ even if $$$i$$$ is not an excursion day).
The first line contains one integer $$$t$$$ ($$$1 \le t \le 50$$$) — the number of testcases.
Then the testcases follow, each consists of two lines. The first line contains three integers $$$n$$$, $$$k_1$$$, $$$k_2$$$ ($$$1 \le n \le 5000$$$; $$$1 \le k_1 \le k_2 \le 200\,000$$$).
The second line contains one string $$$s$$$ consisting of exactly $$$n$$$ characters, each character is either 0 or 1. If $$$s_i = 0$$$, then day $$$i$$$ is an excursion day (so there should be no lectures during that day); if $$$s_i = 1$$$, then day $$$i$$$ is not an excursion day.
For each test case, print one integer — the maximum possible value of $$$m$$$ (the number of lectures that can be conducted).
4 4 5 7 1011 4 4 10 0101 5 3 4 11011 6 4 6 011101
12 8 8 14