Submission #147578

#TimeUsernameProblemLanguageResultExecution timeMemory
147578Ruxandra985Telefoni (COCI17_telefoni)C++14
80 / 80
28 ms1528 KiB
#include <cstdio> using namespace std; int v[300010]; int main() { int n,d,i,latest,add=0; scanf ("%d%d",&n,&d); for (i=1;i<=n;i++) scanf ("%d",&v[i]); latest = 1; for (i=2;i<=n;i++){ if ( i - latest == d ){ if (!v[i]){ add++; latest = i; } } if (v[i]) latest = i; } printf ("%d",add); return 0; }

Compilation message (stderr)

telefoni.cpp: In function 'int main()':
telefoni.cpp:8:11: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf ("%d%d",&n,&d);
     ~~~~~~^~~~~~~~~~~~~~
telefoni.cpp:10:15: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf ("%d",&v[i]);
         ~~~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...