Submission #770641

#TimeUsernameProblemLanguageResultExecution timeMemory
770641AmylopectinBigger segments (IZhO19_segments)C++14
0 / 100
0 ms212 KiB
#include <stdio.h> #include <iostream> using namespace std; const int mxn = 1e6 + 10; int a[mxn] = {}; int main() { int i,j,n,m,cou = 1,be,csu,lo,dif; scanf("%d",&n); for(i=0; i<n; i++) { scanf("%d",&a[i]); } be = a[0]; csu = 0; lo = 1; for(i=1; i<n; i++) { csu += a[i]; if(csu >= be) { dif = csu - be; for(j=lo; j<i; j++) { if(a[j] * 2 > dif) { break; } dif -= a[j] * 2; csu -= a[j]; } lo = i+1; be = csu; cou ++; csu = 0; } } printf("%d\n",cou); }

Compilation message (stderr)

segments.cpp: In function 'int main()':
segments.cpp:9:15: warning: unused variable 'm' [-Wunused-variable]
    9 |     int i,j,n,m,cou = 1,be,csu,lo,dif;
      |               ^
segments.cpp:10:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   10 |     scanf("%d",&n);
      |     ~~~~~^~~~~~~~~
segments.cpp:13:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 |         scanf("%d",&a[i]);
      |         ~~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...