| TheForces Round #35 (LOL-Forces) |
|---|
| Finished |
You are given a binary string$$$^\dagger$$$ $$$s$$$ of length $$$n$$$ and an integer $$$k$$$.
You are allowed to do the following operation on $$$s$$$ :
What are the maximum number of $$$1$$$'s in $$$s$$$ after performing the above operation infinitely many times (possibly zero)?
$$$^\dagger$$$ A binary string is a string which only contains $$$0$$$'s and $$$1$$$'s.
Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 100$$$). The description of the test cases follows.
The first line of each testcase contains two integers $$$n,k$$$ ($$$2 \le n \le 10^3$$$, $$$1 \le k \le ⌊\frac{n}{2}⌋$$$), the length of binary string and an integer.
The second line of each testcase contains a binary string $$$s$$$ of length $$$n$$$.
For each test case, print a single integer — the maximum number of $$$1$$$'s in $$$s$$$ after performing the above operation infinitely many times(possibly zero).
62 1002 1013 11013 11114 211004 11010
1 1 2 3 2 3
In the $$$6$$$-th test case, $$$s = 1010$$$ and $$$k = 1$$$
Let choose $$$i = 2$$$, now $$$s_2$$$ becomes $$$1$$$ and $$$s_3$$$ becomes $$$0$$$. So $$$s = 1100$$$.
Let choose $$$i = 3$$$, now $$$s_3$$$ becomes $$$1$$$ and $$$s_4$$$ becomes $$$0$$$. So $$$s = 1110$$$.
Hence, maximum number of $$$1$$$'s in $$$s = 1110$$$ is $$$3$$$.
| Name |
|---|


