Submission #244234

#TimeUsernameProblemLanguageResultExecution timeMemory
244234aintaBigger segments (IZhO19_segments)C++17
100 / 100
135 ms15096 KiB
#include<cstdio> #include<algorithm> using namespace std; long long S[501000]; int w[501000], n, D[501000], P[501000], res; int main(){ int i; scanf("%d",&n); for(i=1;i<=n;i++){ scanf("%d",&w[i]); S[i]=S[i-1]+w[i]; } for(i=1;i<=n;i++){ P[i]=max(P[i],P[i-1]); D[i]=D[P[i]]+1; long long s = S[i]+S[i]-S[P[i]]; int pv = lower_bound(S+1,S+n+1,s)-S; P[pv]=max(P[pv],i); } printf("%d\n",D[n]); }

Compilation message (stderr)

segments.cpp: In function 'int main()':
segments.cpp:8:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d",&n);
     ~~~~~^~~~~~~~~
segments.cpp:10:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d",&w[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...