Submission #369630

# Submission time Handle Problem Language Result Execution time Memory
369630 2021-02-22T06:33:22 Z Mamnoon_Siam Candies (JOI18_candies) C++17
0 / 100
1 ms 620 KB
#include <bits/stdc++.h>
using namespace std;

/* sorry, this is the bare minimum :'( */
using ll = long long;
using ii = pair<int, int>;
using vi = vector<int>;
#define all(v) begin(v), end(v)
#define sz(v) (int)(v).size()
#define fi first
#define se second

const int N = 50;
const ll inf = 1e18;
ll a[N], dp[N][N];

int main(int argc, char const *argv[])
{
  cin.sync_with_stdio(0); cin.tie(0);
  cin.exceptions(cin.failbit);
#ifdef LOCAL
  freopen("in", "r", stdin);
#endif
  int n; cin >> n;
  fill(dp[0]+1, dp[0]+N, -inf);
  ll y; cin >> y;
  fill(dp[1]+1, dp[1]+N, -inf);
  dp[1][1] = y;
  for(int i = 2; i <= n; ++i) {
    ll x; cin >> x;
    for(int j = 0; j <= n; ++j) {
      dp[i][j] = dp[i-1][j];
      if(i >= 2 and j) dp[i][j] = max(dp[i][j], dp[i-2][j-1] + x);
    }
  }
  for(int i = 1; i <= (n-1)/2+1; ++i) {
    cout << dp[n][i] << "\n";
  }
  return 0;
}
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 620 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 620 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -