Submission #218100

#TimeUsernameProblemLanguageResultExecution timeMemory
218100extraterrestrialCandies (JOI18_candies)C++14
8 / 100
30 ms32248 KiB
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;
#define F first
#define S second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define SZ(x) (int)(x).size()
#define int ll

const int N = 2010;
int a[N], dp[N][N];

signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
	int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
  }		
  for (int i = 0; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      dp[i][j] = -1e18;
    }
  }
  dp[1][1] = a[1];
  for (int i = 2; i <= n; i++) {
    for (int j = 1; j <= i; j++) {
      dp[i][j] = max(dp[i - 1][j], dp[i - 2][j - 1] + a[i]);
    }
  }
  for (int i = 1; i <= (n + 1) / 2; i++) {
    cout << dp[n][i] << '\n';
  }
  cout << '\n';
} 
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...