Submission #369631

# Submission time Handle Problem Language Result Execution time Memory
369631 2021-02-22T06:33:45 Z Mamnoon_Siam Candies (JOI18_candies) C++17
8 / 100
1416 ms 398188 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 = 5005;
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 Correct 23 ms 39788 KB Output is correct
2 Correct 26 ms 39916 KB Output is correct
3 Correct 23 ms 39916 KB Output is correct
4 Correct 23 ms 39916 KB Output is correct
5 Correct 24 ms 39916 KB Output is correct
6 Correct 24 ms 39936 KB Output is correct
7 Correct 24 ms 39916 KB Output is correct
8 Correct 24 ms 39916 KB Output is correct
9 Correct 23 ms 39916 KB Output is correct
10 Correct 24 ms 39916 KB Output is correct
11 Correct 23 ms 39788 KB Output is correct
12 Correct 26 ms 39788 KB Output is correct
13 Correct 24 ms 39788 KB Output is correct
14 Correct 24 ms 39788 KB Output is correct
15 Correct 30 ms 39788 KB Output is correct
16 Correct 24 ms 39788 KB Output is correct
17 Correct 24 ms 39788 KB Output is correct
18 Correct 27 ms 39788 KB Output is correct
19 Correct 24 ms 39788 KB Output is correct
20 Correct 24 ms 39788 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 23 ms 39788 KB Output is correct
2 Correct 26 ms 39916 KB Output is correct
3 Correct 23 ms 39916 KB Output is correct
4 Correct 23 ms 39916 KB Output is correct
5 Correct 24 ms 39916 KB Output is correct
6 Correct 24 ms 39936 KB Output is correct
7 Correct 24 ms 39916 KB Output is correct
8 Correct 24 ms 39916 KB Output is correct
9 Correct 23 ms 39916 KB Output is correct
10 Correct 24 ms 39916 KB Output is correct
11 Correct 23 ms 39788 KB Output is correct
12 Correct 26 ms 39788 KB Output is correct
13 Correct 24 ms 39788 KB Output is correct
14 Correct 24 ms 39788 KB Output is correct
15 Correct 30 ms 39788 KB Output is correct
16 Correct 24 ms 39788 KB Output is correct
17 Correct 24 ms 39788 KB Output is correct
18 Correct 27 ms 39788 KB Output is correct
19 Correct 24 ms 39788 KB Output is correct
20 Correct 24 ms 39788 KB Output is correct
21 Runtime error 1416 ms 398188 KB Execution killed with signal 11
22 Halted 0 ms 0 KB -