Submission #526323

#TimeUsernameProblemLanguageResultExecution timeMemory
526323Bill_00Bigger segments (IZhO19_segments)C++14
0 / 100
1 ms480 KiB
#include<bits/stdc++.h> #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); } for(i=1;i<=n;i++){ cout << P[i] << endl; } printf("%d\n",D[n]); }

Compilation message (stderr)

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