# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
545420 | krit3379 | Bigger segments (IZhO19_segments) | C++17 | 90 ms | 16944 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>
using namespace std;
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#define N 500005
long long a[N];
pair<int,long long> dp[N];
int main(){
int n,i;
scanf("%d",&n);
for(i=1;i<=n;i++)scanf("%lld",&a[i]),a[i]+=a[i-1];
dp[0]={1,0};
for(i=1;i<=n;i++){
dp[i]=max(dp[i],dp[i-1]);
int pos=lower_bound(a+1,a+n+1,2*a[i]-dp[i].second)-a;
dp[pos]=max(dp[pos],{dp[i].first+1,a[i]});
}
printf("%d",dp[n].first);
return 0;
}
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... |