Submission #209989

#TimeUsernameProblemLanguageResultExecution timeMemory
209989AlainSuTelefoni (COCI17_telefoni)C++14
24 / 80
1098 ms1144 KiB
#include<bits/stdc++.h> using namespace std; const int MAXN=4000000; long long n,m,ans=0; 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,tmp; 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; }

Compilation message (stderr)

telefoni.cpp: In function 'void process()':
telefoni.cpp:23:3: warning: 'tmp' may be used uninitialized in this function [-Wmaybe-uninitialized]
   if (tmp==now)
   ^~
#Verdict Execution timeMemoryGrader output
Fetching results...