Submission #209991

#TimeUsernameProblemLanguageResultExecution timeMemory
209991AlainSuTelefoni (COCI17_telefoni)C++14
24 / 80
1100 ms632 KiB
#include<bits/stdc++.h> using namespace std; const int MAXN=3500000; long long n,m,ans=0,tmp; bool a[MAXN]; void input() { cin>>n>>m; for (int i=1;i<=n;i++) cin>>a[i]; } void process() { int now=1,maxr=m+1; while (maxr<n) { for (int i=maxr;i>=now;i--) if (a[i]) { tmp=i; break; } if (tmp==now) { ans++; now=maxr; } else { now=tmp; } maxr=now+m; } } void output() { cout<<ans; } int main() { input(); process(); output(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...