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;
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 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... |