39 lines
493 B
C++
39 lines
493 B
C++
#include <iostream>
|
|
#include <vector>
|
|
|
|
using namespace std;
|
|
|
|
void solve() {
|
|
int n, k;
|
|
cin >> n >> k;
|
|
vector<int> a(n);
|
|
for (int &i : a)
|
|
cin >> i;
|
|
|
|
int res = 0;
|
|
int len = 0;
|
|
for (int i = 0; i < n; i++) {
|
|
if (len == k) {
|
|
len = 0;
|
|
res++;
|
|
continue;
|
|
}
|
|
if (a[i] == 0) {
|
|
len++;
|
|
}
|
|
if (a[i] == 1) {
|
|
len = 0;
|
|
}
|
|
}
|
|
if (len == k)
|
|
res++;
|
|
cout << res << endl;
|
|
}
|
|
|
|
int main() {
|
|
int t;
|
|
cin >> t;
|
|
while (t--)
|
|
solve();
|
|
}
|