#include <bits/stdc++.h>
#define ll long long
#define endl '\n'
using namespace std;
const int N=2e3+5;
int n;
int a[N];
ll dp[N][N];
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n;
for(int i=1; i<=n; i++) {
cin >> a[i];
}
dp[1][1]=a[1], dp[2][1]=max(a[1], a[2]);
for(int i=3; i<=n; i++) {
for(int q=1; q<=(i+1)/2; q++) {
dp[i][q]=max(dp[i-1][q], dp[i-2][q-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... |