#include<bits/stdc++.h>
using namespace std;
int N, x, last, ans, D;
int main(){
cin >> N >> D >> x;
last = 1;
for( int i = 2; i <= N; i++ ){
cin >> x;
if( x == 1 ){
if( i - last > D ){
ans += (i - last) / D;
if( (i - last) % D == 0 )
ans--;
}
last = i;
}
}
cout << ans << endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
256 KB |
Output is correct |
2 |
Correct |
2 ms |
356 KB |
Output is correct |
3 |
Correct |
2 ms |
360 KB |
Output is correct |
4 |
Correct |
2 ms |
360 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
256 KB |
Output is correct |
8 |
Correct |
79 ms |
888 KB |
Output is correct |
9 |
Correct |
77 ms |
944 KB |
Output is correct |
10 |
Correct |
76 ms |
1016 KB |
Output is correct |