#include <bits/stdc++.h>
#define ll long long
#define S second
#define F first
#define PB push_back
#define PF push_front
const int SIZE = 1e5;
using namespace std;
int main()
{
ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);
int a,b;
cin >> a >> b;
vector<int>V;
for(int i = 0; i < a; i++){
int x;
cin >> x;
V.PB(x);
}
int cnt = 0;
for(int i = 0; i < a-1; i++){
if(V[i+1] == 0){
bool cmp = 0;
int x = 0;
for(int j = i+ b; j > i; j--){
if(V[j] == 1){
cmp = 1;
x = j;
}
}
if(cmp){
i=x;
}
else{
i+=b;
cnt++;
}
}
}
cout<<cnt;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
4 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
5 |
Incorrect |
0 ms |
344 KB |
Output isn't correct |
6 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
7 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
8 |
Incorrect |
12 ms |
3052 KB |
Output isn't correct |
9 |
Incorrect |
12 ms |
3284 KB |
Output isn't correct |
10 |
Incorrect |
12 ms |
3152 KB |
Output isn't correct |