#include<bits/stdc++.h>
#define rep(a,b,c) for(ll a=b;a<=c;++a)
#define ll long long
#define ff first
#define ss second
#define mp make_pair
using namespace std;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll N=2005,inf=1e18;
ll n,A[N],dp[N][N];
ll Ceil(ll a,ll b){return (a+b-1)/b;}
signed main(){
ios::sync_with_stdio(0);cin.tie(0);
cin>>n;
rep(i,1,n) cin>>A[i];
rep(i,1,n) rep(j,1,i) dp[i][j]=-inf;
dp[1][1]=A[1];
rep(i,2,n) rep(j,1,Ceil(i,2)) dp[i][j]=max(dp[i-1][j],dp[i-2][j-1]+A[i]);
rep(i,1,Ceil(n,2)) cout<<dp[n][i]<<'\n';
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |