Submission #253647

#TimeUsernameProblemLanguageResultExecution timeMemory
253647_ypcBigger segments (IZhO19_segments)C++98
100 / 100
99 ms13080 KiB
#include <bits/stdc++.h> using namespace std; typedef long long LL; const int maxn=5e5+5; LL n,a[maxn],f[maxn],sum[maxn],ans; inline LL rad(){ int ret=0,flg=1;char ch=getchar(); while (!isdigit(ch)){if (ch=='-')flg=-1;ch=getchar();} while (isdigit(ch))ret=ret*10+ch-'0',ch=getchar(); return ret*flg; } int main (){ n=rad(); for (int i=1;i<=n;i++)sum[i]=sum[i-1]+rad(); for (int i=1;i<=n;i++){ f[i]=max(f[i],f[i-1]); LL tmp=sum[i]-sum[f[i]]; int lp=lower_bound(sum+1,sum+1+n,sum[i]+tmp)-sum; f[lp]=i; } for (int i=n;i;i=f[i])ans++; printf("%lld\n",ans); return 0; }
#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...