# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1108869 | LM1 | Bigger segments (IZhO19_segments) | C++17 | 1 ms | 504 KiB |
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;
#define int long long
#define ll long long
#define pii pair<int,int>
#define pb push_back
#define ff first
#define ss second
const int N=505;
int n,a[N],dp[N][N],pr[N],ans;
main(){
ios_base::sync_with_stdio(NULL);cin.tie(NULL);
cin>>n;
for(int i=1;i<=n;i++){
cin>>a[i];
pr[i]=pr[i-1]+a[i];
}
dp[1][1]=1;
for(int j=1;j<=n;j++){
for(int i=1;i<=j;i++){
for(int i1=i-1;i1>=1;i1--){
int j1=i-1;
int sum=pr[j]-pr[i-1];
int sum1=pr[j1]-pr[i1-1];
if(sum1>sum)continue;
dp[i][j]=max(dp[i][j],dp[i1][j1]+1);
}
}
}
for(int i=1;i<=n;i++)ans=max(ans,dp[i][n]);
cout<<ans;
}
Compilation message (stderr)
# | 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... |