답안 #867689

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
867689 2023-10-29T08:06:25 Z TAhmed33 Uplifting Excursion (BOI22_vault) C++
20 / 100
3295 ms 19284 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll bad = -1e17;
const ll MAXN = 6e5;
ll dp[2 * MAXN], dq[2 * MAXN], n, l;
bool ok (ll x) {
    return x >= -MAXN && x < MAXN;
}
void chmax (ll &a, ll b) {
    a = max(a, b);
}
void insert (ll a, ll b) {
    for (ll i = -MAXN; i < MAXN; i++) {
        dq[i + MAXN] = dp[i + MAXN];
        if (ok(i - a * b)) chmax(dq[i + MAXN], b + dp[i - a * b + MAXN]);
    }
    if (ok(a * b)) chmax(dq[a * b + MAXN], b);
    for (ll i = -MAXN; i < MAXN; i++) dp[i + MAXN] = dq[i + MAXN];
}
int main () {
    cin >> n >> l;
    for (auto &i : dp) i = bad;
	for (ll i = -n; i <= n; i++) {
        int x;
        cin >> x;
        int u = 0;
        while ((1 << u) <= x) {
            insert(i, (1 << u));
            x -= (1 << u);
            u++;
        }
        if (x) insert(i, x);
    }
    if (!ok(l)) {
        cout << "impossible\n";
    } else if (dp[l + MAXN] < 0) {
        cout << "impossible\n";
    } else {
        cout << dp[l + MAXN] << '\n';
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 22 ms 19036 KB Output is correct
2 Correct 18 ms 19036 KB Output is correct
3 Correct 9 ms 19216 KB Output is correct
4 Correct 77 ms 19200 KB Output is correct
5 Correct 1136 ms 19284 KB Output is correct
6 Correct 1202 ms 19200 KB Output is correct
7 Correct 472 ms 19192 KB Output is correct
8 Correct 1143 ms 19200 KB Output is correct
9 Correct 1410 ms 19200 KB Output is correct
10 Correct 40 ms 19036 KB Output is correct
11 Correct 44 ms 19204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 22 ms 19036 KB Output is correct
2 Correct 18 ms 19036 KB Output is correct
3 Correct 9 ms 19216 KB Output is correct
4 Correct 77 ms 19200 KB Output is correct
5 Correct 1136 ms 19284 KB Output is correct
6 Correct 1202 ms 19200 KB Output is correct
7 Correct 472 ms 19192 KB Output is correct
8 Correct 1143 ms 19200 KB Output is correct
9 Correct 1410 ms 19200 KB Output is correct
10 Correct 40 ms 19036 KB Output is correct
11 Correct 44 ms 19204 KB Output is correct
12 Correct 24 ms 19032 KB Output is correct
13 Correct 18 ms 19036 KB Output is correct
14 Correct 10 ms 19032 KB Output is correct
15 Correct 70 ms 19036 KB Output is correct
16 Correct 1102 ms 19196 KB Output is correct
17 Correct 1145 ms 19036 KB Output is correct
18 Correct 485 ms 19036 KB Output is correct
19 Correct 1143 ms 19196 KB Output is correct
20 Correct 1448 ms 19200 KB Output is correct
21 Correct 40 ms 19032 KB Output is correct
22 Correct 51 ms 19032 KB Output is correct
23 Correct 2688 ms 19204 KB Output is correct
24 Correct 2727 ms 19200 KB Output is correct
25 Correct 1020 ms 19200 KB Output is correct
26 Correct 3295 ms 19204 KB Output is correct
27 Correct 3288 ms 19204 KB Output is correct
28 Correct 46 ms 19032 KB Output is correct
29 Correct 77 ms 19204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 75 ms 19032 KB Output is correct
2 Incorrect 170 ms 19200 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 75 ms 19032 KB Output is correct
2 Incorrect 170 ms 19200 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 75 ms 19032 KB Output is correct
2 Incorrect 170 ms 19200 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 22 ms 19036 KB Output is correct
2 Correct 18 ms 19036 KB Output is correct
3 Correct 9 ms 19216 KB Output is correct
4 Correct 77 ms 19200 KB Output is correct
5 Correct 1136 ms 19284 KB Output is correct
6 Correct 1202 ms 19200 KB Output is correct
7 Correct 472 ms 19192 KB Output is correct
8 Correct 1143 ms 19200 KB Output is correct
9 Correct 1410 ms 19200 KB Output is correct
10 Correct 40 ms 19036 KB Output is correct
11 Correct 44 ms 19204 KB Output is correct
12 Correct 75 ms 19032 KB Output is correct
13 Incorrect 170 ms 19200 KB Output isn't correct
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 75 ms 19032 KB Output is correct
2 Incorrect 170 ms 19200 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 22 ms 19036 KB Output is correct
2 Correct 18 ms 19036 KB Output is correct
3 Correct 9 ms 19216 KB Output is correct
4 Correct 77 ms 19200 KB Output is correct
5 Correct 1136 ms 19284 KB Output is correct
6 Correct 1202 ms 19200 KB Output is correct
7 Correct 472 ms 19192 KB Output is correct
8 Correct 1143 ms 19200 KB Output is correct
9 Correct 1410 ms 19200 KB Output is correct
10 Correct 40 ms 19036 KB Output is correct
11 Correct 44 ms 19204 KB Output is correct
12 Correct 24 ms 19032 KB Output is correct
13 Correct 18 ms 19036 KB Output is correct
14 Correct 10 ms 19032 KB Output is correct
15 Correct 70 ms 19036 KB Output is correct
16 Correct 1102 ms 19196 KB Output is correct
17 Correct 1145 ms 19036 KB Output is correct
18 Correct 485 ms 19036 KB Output is correct
19 Correct 1143 ms 19196 KB Output is correct
20 Correct 1448 ms 19200 KB Output is correct
21 Correct 40 ms 19032 KB Output is correct
22 Correct 51 ms 19032 KB Output is correct
23 Correct 2688 ms 19204 KB Output is correct
24 Correct 2727 ms 19200 KB Output is correct
25 Correct 1020 ms 19200 KB Output is correct
26 Correct 3295 ms 19204 KB Output is correct
27 Correct 3288 ms 19204 KB Output is correct
28 Correct 46 ms 19032 KB Output is correct
29 Correct 77 ms 19204 KB Output is correct
30 Correct 75 ms 19032 KB Output is correct
31 Incorrect 170 ms 19200 KB Output isn't correct
32 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 75 ms 19032 KB Output is correct
2 Incorrect 170 ms 19200 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 22 ms 19036 KB Output is correct
2 Correct 18 ms 19036 KB Output is correct
3 Correct 9 ms 19216 KB Output is correct
4 Correct 77 ms 19200 KB Output is correct
5 Correct 1136 ms 19284 KB Output is correct
6 Correct 1202 ms 19200 KB Output is correct
7 Correct 472 ms 19192 KB Output is correct
8 Correct 1143 ms 19200 KB Output is correct
9 Correct 1410 ms 19200 KB Output is correct
10 Correct 40 ms 19036 KB Output is correct
11 Correct 44 ms 19204 KB Output is correct
12 Correct 24 ms 19032 KB Output is correct
13 Correct 18 ms 19036 KB Output is correct
14 Correct 10 ms 19032 KB Output is correct
15 Correct 70 ms 19036 KB Output is correct
16 Correct 1102 ms 19196 KB Output is correct
17 Correct 1145 ms 19036 KB Output is correct
18 Correct 485 ms 19036 KB Output is correct
19 Correct 1143 ms 19196 KB Output is correct
20 Correct 1448 ms 19200 KB Output is correct
21 Correct 40 ms 19032 KB Output is correct
22 Correct 51 ms 19032 KB Output is correct
23 Correct 2688 ms 19204 KB Output is correct
24 Correct 2727 ms 19200 KB Output is correct
25 Correct 1020 ms 19200 KB Output is correct
26 Correct 3295 ms 19204 KB Output is correct
27 Correct 3288 ms 19204 KB Output is correct
28 Correct 46 ms 19032 KB Output is correct
29 Correct 77 ms 19204 KB Output is correct
30 Correct 75 ms 19032 KB Output is correct
31 Incorrect 170 ms 19200 KB Output isn't correct
32 Halted 0 ms 0 KB -