Submission #867688

# Submission time Handle Problem Language Result Execution time Memory
867688 2023-10-29T08:05:27 Z TAhmed33 Uplifting Excursion (BOI22_vault) C++
5 / 100
319 ms 3720 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll bad = -1e17;
const ll MAXN = 1e5;
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];
    for (ll i = -MAXN; i < MAXN; i++) {
        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';
    }
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 3564 KB Output is correct
2 Correct 3 ms 3420 KB Output is correct
3 Correct 2 ms 3420 KB Output is correct
4 Correct 9 ms 3420 KB Output is correct
5 Correct 121 ms 3420 KB Output is correct
6 Correct 124 ms 3544 KB Output is correct
7 Correct 54 ms 3544 KB Output is correct
8 Correct 122 ms 3416 KB Output is correct
9 Correct 150 ms 3416 KB Output is correct
10 Correct 5 ms 3420 KB Output is correct
11 Correct 5 ms 3420 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 3564 KB Output is correct
2 Correct 3 ms 3420 KB Output is correct
3 Correct 2 ms 3420 KB Output is correct
4 Correct 9 ms 3420 KB Output is correct
5 Correct 121 ms 3420 KB Output is correct
6 Correct 124 ms 3544 KB Output is correct
7 Correct 54 ms 3544 KB Output is correct
8 Correct 122 ms 3416 KB Output is correct
9 Correct 150 ms 3416 KB Output is correct
10 Correct 5 ms 3420 KB Output is correct
11 Correct 5 ms 3420 KB Output is correct
12 Correct 3 ms 3588 KB Output is correct
13 Correct 3 ms 3420 KB Output is correct
14 Correct 2 ms 3420 KB Output is correct
15 Correct 8 ms 3420 KB Output is correct
16 Correct 121 ms 3420 KB Output is correct
17 Correct 121 ms 3408 KB Output is correct
18 Correct 54 ms 3720 KB Output is correct
19 Correct 123 ms 3536 KB Output is correct
20 Correct 150 ms 3540 KB Output is correct
21 Correct 5 ms 3416 KB Output is correct
22 Correct 5 ms 3420 KB Output is correct
23 Correct 319 ms 3544 KB Output is correct
24 Incorrect 293 ms 3420 KB Output isn't correct
25 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 3420 KB Output is correct
2 Incorrect 21 ms 3568 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 3420 KB Output is correct
2 Incorrect 21 ms 3568 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 3420 KB Output is correct
2 Incorrect 21 ms 3568 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 3564 KB Output is correct
2 Correct 3 ms 3420 KB Output is correct
3 Correct 2 ms 3420 KB Output is correct
4 Correct 9 ms 3420 KB Output is correct
5 Correct 121 ms 3420 KB Output is correct
6 Correct 124 ms 3544 KB Output is correct
7 Correct 54 ms 3544 KB Output is correct
8 Correct 122 ms 3416 KB Output is correct
9 Correct 150 ms 3416 KB Output is correct
10 Correct 5 ms 3420 KB Output is correct
11 Correct 5 ms 3420 KB Output is correct
12 Correct 8 ms 3420 KB Output is correct
13 Incorrect 21 ms 3568 KB Output isn't correct
14 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 3420 KB Output is correct
2 Incorrect 21 ms 3568 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 3564 KB Output is correct
2 Correct 3 ms 3420 KB Output is correct
3 Correct 2 ms 3420 KB Output is correct
4 Correct 9 ms 3420 KB Output is correct
5 Correct 121 ms 3420 KB Output is correct
6 Correct 124 ms 3544 KB Output is correct
7 Correct 54 ms 3544 KB Output is correct
8 Correct 122 ms 3416 KB Output is correct
9 Correct 150 ms 3416 KB Output is correct
10 Correct 5 ms 3420 KB Output is correct
11 Correct 5 ms 3420 KB Output is correct
12 Correct 3 ms 3588 KB Output is correct
13 Correct 3 ms 3420 KB Output is correct
14 Correct 2 ms 3420 KB Output is correct
15 Correct 8 ms 3420 KB Output is correct
16 Correct 121 ms 3420 KB Output is correct
17 Correct 121 ms 3408 KB Output is correct
18 Correct 54 ms 3720 KB Output is correct
19 Correct 123 ms 3536 KB Output is correct
20 Correct 150 ms 3540 KB Output is correct
21 Correct 5 ms 3416 KB Output is correct
22 Correct 5 ms 3420 KB Output is correct
23 Correct 319 ms 3544 KB Output is correct
24 Incorrect 293 ms 3420 KB Output isn't correct
25 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 8 ms 3420 KB Output is correct
2 Incorrect 21 ms 3568 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 3564 KB Output is correct
2 Correct 3 ms 3420 KB Output is correct
3 Correct 2 ms 3420 KB Output is correct
4 Correct 9 ms 3420 KB Output is correct
5 Correct 121 ms 3420 KB Output is correct
6 Correct 124 ms 3544 KB Output is correct
7 Correct 54 ms 3544 KB Output is correct
8 Correct 122 ms 3416 KB Output is correct
9 Correct 150 ms 3416 KB Output is correct
10 Correct 5 ms 3420 KB Output is correct
11 Correct 5 ms 3420 KB Output is correct
12 Correct 3 ms 3588 KB Output is correct
13 Correct 3 ms 3420 KB Output is correct
14 Correct 2 ms 3420 KB Output is correct
15 Correct 8 ms 3420 KB Output is correct
16 Correct 121 ms 3420 KB Output is correct
17 Correct 121 ms 3408 KB Output is correct
18 Correct 54 ms 3720 KB Output is correct
19 Correct 123 ms 3536 KB Output is correct
20 Correct 150 ms 3540 KB Output is correct
21 Correct 5 ms 3416 KB Output is correct
22 Correct 5 ms 3420 KB Output is correct
23 Correct 319 ms 3544 KB Output is correct
24 Incorrect 293 ms 3420 KB Output isn't correct
25 Halted 0 ms 0 KB -