#include <bits/stdc++.h>
#define F first
#define S second
#define ll long long
#define EB emplace_back
using namespace std;
const int SIZE = 1e5 + 1;
const int MOD = 1e9 + 7;
int main() {
ios_base::sync_with_stdio(0); cin.tie(nullptr);
int n, d; cin >> n >> d;
vector<int> M(n + 1);
for (int i = 1; i <= n; i ++) {
cin >> M[i];
}
int x = 0;
int cnt = 0;
for (int i = 1; i <= n; i ++) {
if (M[i] == 0) {
if (i - x >= d) {
M[i] = 1;
cnt ++;
}
}
for (int j = i; j <= n; j += d) {
if (M[i] == 1) {
x = i;
}
}
}
cout << cnt << "\n"; // muestra el cnt
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
316 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
247 ms |
2004 KB |
Output is correct |
9 |
Execution timed out |
1072 ms |
2004 KB |
Time limit exceeded |
10 |
Correct |
120 ms |
2004 KB |
Output is correct |