Submission #173530

#TimeUsernameProblemLanguageResultExecution timeMemory
173530mosiashvililukaBigger segments (IZhO19_segments)C++14
0 / 100
2 ms376 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=dp[c].second; }else{ if(dp[c].first+1==dp[b].first&&dp[c].second<dp[b].second) dp[b].second=dp[c].second; } } 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...