답안 #893268

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
893268 2023-12-26T19:25:20 Z box Candies (JOI18_candies) C++17
8 / 100
283 ms 524288 KB
#include <bits/stdc++.h>
using namespace std;

#define ar array
#define sz(v) int(std::size(v))
using i64 = long long;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    vector<int> A(N);
    for (auto &x : A) cin >> x;
    int take = (N + 1) / 2;
    vector dp(N, vector<i64>(take + 1, LLONG_MIN));
    dp[0][0] = 0;
    for (int i = 0; i < N; i++) {
        if (i) dp[i] = dp[i - 1];
        for (int j = 1; j <= take; j++)
            dp[i][j] = max(dp[i][j], (i >= 2 ? dp[i - 2][j - 1] : j == 1 ? 0 : LLONG_MIN) + A[i]);
    }
    for (int j = 1; j <= take; j++) cout << dp[N - 1][j] << '\n';
}
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 16220 KB Output is correct
2 Correct 9 ms 16136 KB Output is correct
3 Correct 9 ms 16020 KB Output is correct
4 Correct 9 ms 16244 KB Output is correct
5 Correct 8 ms 16220 KB Output is correct
6 Correct 9 ms 16080 KB Output is correct
7 Correct 9 ms 16220 KB Output is correct
8 Correct 10 ms 16084 KB Output is correct
9 Correct 9 ms 16216 KB Output is correct
10 Correct 10 ms 16220 KB Output is correct
11 Correct 9 ms 16220 KB Output is correct
12 Correct 10 ms 16220 KB Output is correct
13 Correct 10 ms 16216 KB Output is correct
14 Correct 9 ms 16084 KB Output is correct
15 Correct 9 ms 16220 KB Output is correct
16 Correct 9 ms 16220 KB Output is correct
17 Correct 9 ms 16220 KB Output is correct
18 Correct 9 ms 16220 KB Output is correct
19 Correct 9 ms 16220 KB Output is correct
20 Correct 12 ms 16220 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 9 ms 16220 KB Output is correct
2 Correct 9 ms 16136 KB Output is correct
3 Correct 9 ms 16020 KB Output is correct
4 Correct 9 ms 16244 KB Output is correct
5 Correct 8 ms 16220 KB Output is correct
6 Correct 9 ms 16080 KB Output is correct
7 Correct 9 ms 16220 KB Output is correct
8 Correct 10 ms 16084 KB Output is correct
9 Correct 9 ms 16216 KB Output is correct
10 Correct 10 ms 16220 KB Output is correct
11 Correct 9 ms 16220 KB Output is correct
12 Correct 10 ms 16220 KB Output is correct
13 Correct 10 ms 16216 KB Output is correct
14 Correct 9 ms 16084 KB Output is correct
15 Correct 9 ms 16220 KB Output is correct
16 Correct 9 ms 16220 KB Output is correct
17 Correct 9 ms 16220 KB Output is correct
18 Correct 9 ms 16220 KB Output is correct
19 Correct 9 ms 16220 KB Output is correct
20 Correct 12 ms 16220 KB Output is correct
21 Runtime error 283 ms 524288 KB Execution killed with signal 9
22 Halted 0 ms 0 KB -