# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
526323 | Bill_00 | Bigger segments (IZhO19_segments) | C++14 | 1 ms | 480 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |