답안 #949639

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
949639 2024-03-19T13:43:05 Z ifateen Uplifting Excursion (BOI22_vault) C++17
20 / 100
2519 ms 16472 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int OFFSET_SUM = 5e5 + 5e3 + 5, MAXN = 1e6 + 1e4 + 69;
int dp[2][MAXN + 1];

void add(int x, int count) {
    int diff = x * count;
    for (int i = 0; i <= MAXN; ++i) {
        dp[1][i] = dp[0][i];
        if (0 <= i - diff && i - diff <= MAXN) dp[1][i] = max(dp[1][i], dp[0][i - diff] + count);
    }
    for (int i = 0; i <= MAXN; ++i) dp[0][i] = dp[1][i];
}

signed main() {
    for (auto& i : dp[0]) i = -1e9;
    for (auto& i : dp[1]) i = -1e9;
    dp[0][OFFSET_SUM] = 0;
    int n, l;
    cin >> n >> l;
    for (int i = -n; i <= n; ++i) {
        int x;
        cin >> x;
        int cnt = 1;
        while (cnt <= x) {
            add(i, cnt);
            x -= cnt;
            cnt *= 2;
        }
        if (x > 0) add(i, x);
    }
    if (-OFFSET_SUM > l || l > OFFSET_SUM) {
        cout << "impossible";
        return 0;
    }
    int ans = dp[0][OFFSET_SUM + l];
    if (ans < 0) cout << "impossible";
    else cout << ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 21 ms 16216 KB Output is correct
2 Correct 15 ms 16220 KB Output is correct
3 Correct 9 ms 16216 KB Output is correct
4 Correct 57 ms 16220 KB Output is correct
5 Correct 864 ms 16228 KB Output is correct
6 Correct 902 ms 16220 KB Output is correct
7 Correct 382 ms 16220 KB Output is correct
8 Correct 913 ms 16224 KB Output is correct
9 Correct 1131 ms 16468 KB Output is correct
10 Correct 32 ms 16216 KB Output is correct
11 Correct 32 ms 16220 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 21 ms 16216 KB Output is correct
2 Correct 15 ms 16220 KB Output is correct
3 Correct 9 ms 16216 KB Output is correct
4 Correct 57 ms 16220 KB Output is correct
5 Correct 864 ms 16228 KB Output is correct
6 Correct 902 ms 16220 KB Output is correct
7 Correct 382 ms 16220 KB Output is correct
8 Correct 913 ms 16224 KB Output is correct
9 Correct 1131 ms 16468 KB Output is correct
10 Correct 32 ms 16216 KB Output is correct
11 Correct 32 ms 16220 KB Output is correct
12 Correct 20 ms 16216 KB Output is correct
13 Correct 15 ms 16220 KB Output is correct
14 Correct 9 ms 16220 KB Output is correct
15 Correct 58 ms 16220 KB Output is correct
16 Correct 883 ms 16224 KB Output is correct
17 Correct 883 ms 16232 KB Output is correct
18 Correct 371 ms 16240 KB Output is correct
19 Correct 895 ms 16224 KB Output is correct
20 Correct 1065 ms 16228 KB Output is correct
21 Correct 41 ms 16220 KB Output is correct
22 Correct 34 ms 16224 KB Output is correct
23 Correct 2021 ms 16224 KB Output is correct
24 Correct 2029 ms 16224 KB Output is correct
25 Correct 842 ms 16224 KB Output is correct
26 Correct 2517 ms 16224 KB Output is correct
27 Correct 2519 ms 16228 KB Output is correct
28 Correct 39 ms 16220 KB Output is correct
29 Correct 51 ms 16472 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 63 ms 16468 KB Output is correct
2 Incorrect 951 ms 16228 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 63 ms 16468 KB Output is correct
2 Incorrect 951 ms 16228 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 63 ms 16468 KB Output is correct
2 Incorrect 951 ms 16228 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 21 ms 16216 KB Output is correct
2 Correct 15 ms 16220 KB Output is correct
3 Correct 9 ms 16216 KB Output is correct
4 Correct 57 ms 16220 KB Output is correct
5 Correct 864 ms 16228 KB Output is correct
6 Correct 902 ms 16220 KB Output is correct
7 Correct 382 ms 16220 KB Output is correct
8 Correct 913 ms 16224 KB Output is correct
9 Correct 1131 ms 16468 KB Output is correct
10 Correct 32 ms 16216 KB Output is correct
11 Correct 32 ms 16220 KB Output is correct
12 Correct 63 ms 16468 KB Output is correct
13 Incorrect 951 ms 16228 KB Output isn't correct
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 63 ms 16468 KB Output is correct
2 Incorrect 951 ms 16228 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 21 ms 16216 KB Output is correct
2 Correct 15 ms 16220 KB Output is correct
3 Correct 9 ms 16216 KB Output is correct
4 Correct 57 ms 16220 KB Output is correct
5 Correct 864 ms 16228 KB Output is correct
6 Correct 902 ms 16220 KB Output is correct
7 Correct 382 ms 16220 KB Output is correct
8 Correct 913 ms 16224 KB Output is correct
9 Correct 1131 ms 16468 KB Output is correct
10 Correct 32 ms 16216 KB Output is correct
11 Correct 32 ms 16220 KB Output is correct
12 Correct 20 ms 16216 KB Output is correct
13 Correct 15 ms 16220 KB Output is correct
14 Correct 9 ms 16220 KB Output is correct
15 Correct 58 ms 16220 KB Output is correct
16 Correct 883 ms 16224 KB Output is correct
17 Correct 883 ms 16232 KB Output is correct
18 Correct 371 ms 16240 KB Output is correct
19 Correct 895 ms 16224 KB Output is correct
20 Correct 1065 ms 16228 KB Output is correct
21 Correct 41 ms 16220 KB Output is correct
22 Correct 34 ms 16224 KB Output is correct
23 Correct 2021 ms 16224 KB Output is correct
24 Correct 2029 ms 16224 KB Output is correct
25 Correct 842 ms 16224 KB Output is correct
26 Correct 2517 ms 16224 KB Output is correct
27 Correct 2519 ms 16228 KB Output is correct
28 Correct 39 ms 16220 KB Output is correct
29 Correct 51 ms 16472 KB Output is correct
30 Correct 63 ms 16468 KB Output is correct
31 Incorrect 951 ms 16228 KB Output isn't correct
32 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 63 ms 16468 KB Output is correct
2 Incorrect 951 ms 16228 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 21 ms 16216 KB Output is correct
2 Correct 15 ms 16220 KB Output is correct
3 Correct 9 ms 16216 KB Output is correct
4 Correct 57 ms 16220 KB Output is correct
5 Correct 864 ms 16228 KB Output is correct
6 Correct 902 ms 16220 KB Output is correct
7 Correct 382 ms 16220 KB Output is correct
8 Correct 913 ms 16224 KB Output is correct
9 Correct 1131 ms 16468 KB Output is correct
10 Correct 32 ms 16216 KB Output is correct
11 Correct 32 ms 16220 KB Output is correct
12 Correct 20 ms 16216 KB Output is correct
13 Correct 15 ms 16220 KB Output is correct
14 Correct 9 ms 16220 KB Output is correct
15 Correct 58 ms 16220 KB Output is correct
16 Correct 883 ms 16224 KB Output is correct
17 Correct 883 ms 16232 KB Output is correct
18 Correct 371 ms 16240 KB Output is correct
19 Correct 895 ms 16224 KB Output is correct
20 Correct 1065 ms 16228 KB Output is correct
21 Correct 41 ms 16220 KB Output is correct
22 Correct 34 ms 16224 KB Output is correct
23 Correct 2021 ms 16224 KB Output is correct
24 Correct 2029 ms 16224 KB Output is correct
25 Correct 842 ms 16224 KB Output is correct
26 Correct 2517 ms 16224 KB Output is correct
27 Correct 2519 ms 16228 KB Output is correct
28 Correct 39 ms 16220 KB Output is correct
29 Correct 51 ms 16472 KB Output is correct
30 Correct 63 ms 16468 KB Output is correct
31 Incorrect 951 ms 16228 KB Output isn't correct
32 Halted 0 ms 0 KB -