Submission #209996

#TimeUsernameProblemLanguageResultExecution timeMemory
209996AlainSuTelefoni (COCI17_telefoni)C++14
80 / 80
69 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; long long p=1; for (int i=1;i<=n;i++) { cin>>a[i]; if (a[i]) { if (i-p>m) { ans+=(i-p)/m; if ((i-p)%m>0) ans++; ans--; } p=i; } } } void output() { cout<<ans; } int main() { input(); output(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...