Precreation contest files
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
#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();
|
||||
}
|
||||
Reference in New Issue
Block a user