# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
244234 | ainta | Bigger segments (IZhO19_segments) | C++17 | 135 ms | 15096 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<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)
# | 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... |