Submission #77106

#TimeUsernameProblemLanguageResultExecution timeMemory
77106998244353Telefoni (COCI17_telefoni)C++14
80 / 80
30 ms3660 KiB
#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 (stderr)

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