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>
#define ll long long
#define pll pair<ll, ll>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define ld long double
#define sz(a) ((ll)(a).size())
using namespace std;
const ll maxn=2005, inf=1e18;
ll a[maxn], dp[maxn][maxn];
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    ll n; cin >> n;
    for (ll i=1; i<=n; i++) cin >> a[i];
    for (ll i=0; i<=n; i++)
        for (ll j=1; j<=n; j++)
        {
            if (i==0) dp[i][j]=-inf;
            else if (i==1) dp[i][j]=j==1?a[i]:-inf;
            else dp[i][j]=max(dp[i-1][j], dp[i-2][j-1]+a[i]);
        }
    for (ll i=1; i<=(n+1)/2; i++) cout << dp[n][i] << "\n";
}
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... |