# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
77106 | 2018-09-21T12:16:50 Z | 998244353 | Telefoni (COCI17_telefoni) | C++14 | 30 ms | 3660 KB |
#include<cstdio> #include<cstdlib> #include<iostream> using namespace std; int n,d; int main() { scanf("%d %d",&n,&d); int a[n]; for(int i=0;i<n;i++) { scanf("%d",&a[i]); } int temp=0,ans=0; for(int i=1;i<n;i++) { if(a[i]==1&&i-temp<=d) temp=i; else { if(i-temp>d) { temp=i-1; ans+=1; i-=1; } } } printf("%d",ans); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 384 KB | Output is correct |
3 | Correct | 2 ms | 448 KB | Output is correct |
4 | Correct | 2 ms | 448 KB | Output is correct |
5 | Correct | 2 ms | 524 KB | Output is correct |
6 | Correct | 2 ms | 536 KB | Output is correct |
7 | Correct | 2 ms | 588 KB | Output is correct |
8 | Correct | 28 ms | 2304 KB | Output is correct |
9 | Correct | 30 ms | 3052 KB | Output is correct |
10 | Correct | 28 ms | 3660 KB | Output is correct |