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 endl "\n"
typedef long long int ll;
const int N=2e3+5;
ll dp[N][N];
ll a[N];
int main()
{
ios_base:: sync_with_stdio(false); cin.tie(0);
int n; cin>>n;
for(int i=1; i<=n; i++) {
cin>>a[i];
dp[i][1]=max(dp[i-1][1],a[i]);
}
for(int k=2; k<=(n+1/2); k++) {
for(int i=2*k-1; i<=n; i++) {
dp[i][k]=max(dp[i-1][k],dp[i-2][k-1]+a[i]);
}
}
for(int i=1; i<=(n+1)/2; i++) {
cout<<dp[n][i]<<endl;
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |