Codeforces Round 1068 (Div. 2)
A
Sleeping Through Classes
Codeforces
800
原题
←B →
翻译中…

You have $n$ classes today, which are numbered from $1$ to $n$.

翻译中…

The classes are described by a binary string$^{\text{∗}}$ $s$ of length $n$. We call class $i$ important if and only if $s_i = \mathtt 1 $. For each important class, you must stay awake and listen to it.

翻译中…

You are very tired and wish to sleep through as many classes as possible. However, falling asleep takes time. If you listen to an important class $i$, then you cannot fall asleep for the next $k$ classes, i.e., you must also stay awake in classes $i+1, i+2, \ldots, i+k$ (or until the end of the day, if fewer than $k$ classes remain).

翻译中…

For classes that are not important, you may sleep through them unless the rule above forces you to stay awake.

翻译中…

Your task is to find out the maximum number of classes you can sleep through today.

翻译中…

$^{\text{∗}}$A binary string is a string where each character is either $\mathtt{0}$ or $\mathtt{1}$.

翻译中…

Input

翻译中…

Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \le t \le 500$). The description of the test cases follows.

翻译中…

The first line of each test case contains two integers $n$ and $k$ ($1 \le n, k \le 100$).

翻译中…

The second line of each test case contains the string $s$ of length $n$ ($s_i = \mathtt 0$ or $\mathtt 1$).

翻译中…

Output

翻译中…

For each test case, output a single integer — the maximum number of classes you can sleep through today.

翻译中…

Note

翻译中…

In the first test case, you must listen to class $1$ and class $4$. After listening to class $1$, you cannot fall asleep in class $2$. So the only class you can sleep through is class $3$.

翻译中…

In the second test case, you can sleep through all the classes.

翻译中…

In the fourth test case, you can only sleep through classes $1$ and $5$.

翻译中…

样例

Input #1
4
4 1
1001
3 3
000
3 1
001
8 2
01000101
Output #1
1
3
2
2
InputCopy OutputCopy
题目信息
题号
2173A
时间限制
1 s
内存限制
256 MB
标签
贪心
模拟

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。