Submission #172959

#TimeUsernameProblemLanguageResultExecution timeMemory
172959LinusTorvaldsFanBigger segments (IZhO19_segments)C++14
37 / 100
1552 ms2808 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { int n; cin>>n; vector<int>a(n); for(int i=0;i<n;i++)cin>>a[i]; vector<ll>pr(n+1); for(int i=0;i<n;i++)pr[i+1]=pr[i]+a[i]; vector<int>ans(n); vector<ll> ans_sum(n); ll sum=0; for(int i=0;i<n;i++){ sum+=a[i]; ans_sum[i]=sum; ans[i]=1; } for(int i=0;i<n;i++){ sum=0; for(int j=i;j>0;j--){ if(pr[i+1]>=ans_sum[j-1]+pr[j]){ if(ans[i]<ans[j-1]+1){ ans[i]=ans[j-1]+1; ans_sum[i]=pr[i+1]-pr[j]; } } } } cout<<ans[n-1]; 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...