Submission #173533

#TimeUsernameProblemLanguageResultExecution timeMemory
173533mosiashvililukaBigger segments (IZhO19_segments)C++14
37 / 100
1567 ms2356 KiB
#include<bits/stdc++.h> using namespace std; long long a,b,c,d,e,f[500009],pas; pair <long long, long long> dp[500009]; int main(){ ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0); cin>>a; for(b=1; b<=a; b++) cin>>f[b]; for(b=2; b<=a; b++) f[b]+=f[b-1]; for(b=1; b<=a; b++){ dp[b].first=1;dp[b].second=f[b]; for(c=b-1; c>=1; c--){ if(dp[c].second>f[b]-f[c]) continue; if(dp[c].first+1>dp[b].first){ dp[b].first=dp[c].first+1; dp[b].second=f[b]-f[c]; }else{ if(dp[c].first+1==dp[b].first&&f[b]-f[c]<dp[b].second) dp[b].second=f[b]-f[c]; } } if(pas<dp[b].first) pas=dp[b].first; } cout<<pas; 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...