Precreation contest files
This commit is contained in:
BIN
Codeforces/CodeforcesRound1037(Div3)/BNoCasinointheMountains/cpp.out
Executable file
BIN
Codeforces/CodeforcesRound1037(Div3)/BNoCasinointheMountains/cpp.out
Executable file
Binary file not shown.
@@ -0,0 +1,11 @@
|
||||
5
|
||||
5 1
|
||||
0 1 0 0 0
|
||||
7 3
|
||||
0 0 0 0 0 0 0
|
||||
3 1
|
||||
1 1 1
|
||||
4 2
|
||||
0 1 0 1
|
||||
6 2
|
||||
0 0 1 0 0 0
|
||||
@@ -0,0 +1,5 @@
|
||||
3
|
||||
2
|
||||
0
|
||||
0
|
||||
2
|
||||
@@ -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