Submission #1050645

#TimeUsernameProblemLanguageResultExecution timeMemory
1050645MercubytheFirstCandies (JOI18_candies)C++17
8 / 100
198 ms524288 KiB
#include "bits/stdc++.h"
#define pb push_back
#define endl '\n'
#define fi first
#define se second
#define CDIV(a,b) (((a)+(b)-(1))/(b))
using ll = long long;
using ld = long double;
const ll inf = 1e17 + 37;
const ll mod = 1e9 + 7;
const ll N = 3000 + 1;
const ld eps = 1e-9;
const ld PI = acos((ld)-1);

template<typename T, size_t N>
std::ostream& operator<<(std::ostream& os, const std::array<T, N>& a);
template<typename T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& v);
template<typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, const std::pair<T1, T2>& p);
template<typename T>
std::ostream& operator<<(std::ostream& os, const std::set<T>& s);
template<typename T, typename cmp>
std::ostream& operator<<(std::ostream& os, const std::set<T, cmp>& s);
using namespace std;


void solve() {
  ll n;
  cin >> n;
  vector<ll> v(n + 1);
  for(ll i = 1; i <= n; ++i) {
    cin >> v[i];
  }
  vector<vector<ll> > dp(n + 1, vector<ll>(n + 1));
  dp[1][1] = v[1];
  for(ll i = 2; i <= n; ++i) {
    for(ll j = 1; j <= i/2 + i%2; ++j) {
      dp[i][j] = max(dp[i - 1][j], dp[i - 2][j - 1] + v[i]);
    }
  }
  for(ll j = 1; j <= n/2 + n%2; ++j)
    cout << dp[n][j] << endl;
}


signed main()  {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  solve();
}

/*
5
3 5 1 7 6

*/






template<typename T, size_t N>
std::ostream& operator<<(std::ostream& os, const std::array<T, N>& a) {
  os << "[";
  for(size_t i = 0; i + 1 < N; ++i) {
    os << a[i] << ", ";
  }
  if(N > 0)
    os << a[N - 1];
  os << "]";
  return os;
}
 
template<typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, const std::pair<T1, T2>& p) {
  os << "(" << p.first << ", " << p.second << ") ";
  return os;
}
 
template<typename T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& v) {
  os << '[';
  for(auto x : v)
    os << x << ", ";
  os << "] ";
  return os;
}
 
template<typename T>
std::ostream& operator<<(std::ostream& os, const std::set<T>& s) {
  os << "{";
  for(auto x : s)
    os << x << ", ";
  os << "} ";
  return os;
}
//
template<typename T, typename cmp>
std::ostream& operator<<(std::ostream& os, const std::set<T, cmp>& s) {
  os << "{";
  for(auto x : s)
    os << x << ", ";
  os << "} ";
  return os;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...