# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
545406 | krit3379 | Bigger segments (IZhO19_segments) | C++17 | 1 ms | 308 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
int ans=1;
long long a[N],dp[N],h[N],now,pos,val;
int main(){
int n,i;
scanf("%d",&n);
for(i=1;i<=n;i++)scanf("%lld",&a[i]);
for(i=1;i<=n;i++){
dp[ans]+=a[i];
if(dp[ans]>=dp[ans-1]){
h[ans]=i;
while(dp[ans]-a[h[ans-1]+1]>=dp[ans-1]+a[h[ans-1]+1]){
dp[ans]-=a[h[ans-1]+1];
dp[ans-1]+=a[h[ans-1]+1];
h[ans-1]++;
}
ans++;
}
}
printf("%d",ans-1);
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... |