Donkey has a binary string $$$s$$$ of length $$$n$$$ (each $$$s_i \in \{0,1\}$$$). Positions are indexed from $$$0$$$ to $$$n-1$$$. He also has an energy limit $$$E$$$, an integer $$$k$$$, and an integer $$$m$$$.
Donkey starts at position $$$p = 0$$$ and may perform the following actions in any order:
The total energy spent on all actions (including both moves and toggles) must not exceed $$$E$$$.
Your task is to determine the maximum possible number of ones in the array after performing any sequence of actions within the energy limit.
The first line contains an integer $$$t$$$ ($$$1 \leq t \leq 2000$$$) — the number of test cases.
Each test case consists of:
It is guaranteed that $$$\left\lfloor \frac{n}{k} \right\rfloor \le 50$$$.
The sum of $$$n$$$ over all test cases will not exceed $$$1000$$$.
For each test case, output a single integer — the maximum possible number of ones in the string after operations with total energy at most $$$E$$$.
35 2 3 1000006 3 2 00000005 2 2 110101
465
65 1 10 2010105 2 10 3000005 2 3 5111116 2 100 00101012 1 100 5008 3 7 210100101
445528
For the first test case, one optimal sequence is: toggle at $$$p=0$$$ (cost $$$1$$$), move to $$$p=1$$$ (cost $$$1$$$), then toggle at $$$p=1$$$ (cost $$$1$$$). The array changes
For the second test case, $$$m=0$$$, so toggles are free and only movement matters. We can toggle at $$$p=0,1,2$$$ with total movement cost $$$2$$$, which turns all positions into $$$1$$$, so the answer is $$$6$$$.
For the third test case, move to $$$p=1$$$ (cost $$$1$$$) and toggle there (cost $$$1$$$). This flips $$$a_1$$$ and $$$a_3$$$ from $$$0$$$ to $$$1$$$, so
| Name |
|---|


