Submission #573697

# Submission time Handle Problem Language Result Execution time Memory
573697 2022-06-07T05:38:24 Z eecs Uplifting Excursion (BOI22_vault) C++17
40 / 100
4051 ms 1708 KB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

int main() {
    ios::sync_with_stdio(0), cin.tie(0);
    int m;
    ll L, all = 0;
    cin >> m >> L;
    vector<ll> a(m + 1), b(m + 1);
    for (int i = -m; i <= m; i++) {
        if (i < 0) cin >> *new ll;
        else cin >> a[i], all += i * a[i];
    }
    if (all < L) cout << "impossible\n", exit(0);
    ll ans = a[0];
    for (int i = 1; i <= m; i++) {
        b[i] = min(a[i], L / i);
        ans += b[i], L -= b[i] * i, a[i] -= b[i];
    }
    int lim = m * L;
    vector<int> f(2 * lim + 1, -1e9);
    f[lim] = 0;
    for (int i = 1; i <= m; i++) {
        vector<int> g(2 * lim + 1, -1e9);
        for (int j = -lim; j <= lim; j++) if (f[lim + j] > -1e8) {
            for (int k = 0; k <= a[i] && j + i * k <= lim; k++) {
                g[lim + j + i * k] = max(g[lim + j + i * k], f[lim + j] + k);
            }
            for (int k = 0; k <= b[i] && j - i * k >= -lim; k++) {
                g[lim + j - i * k] = max(g[lim + j - i * k], f[lim + j] - k);
            }
        }
        swap(f, g);
    }
    if (f[L + lim] < -1e8) cout << "impossible\n";
    else cout << ans + f[L + lim] << "\n";
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Incorrect 0 ms 212 KB Output isn't correct
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 232 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 2 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 2 ms 340 KB Output is correct
25 Correct 8 ms 340 KB Output is correct
26 Correct 5 ms 212 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 232 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 2 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 2 ms 340 KB Output is correct
25 Correct 8 ms 340 KB Output is correct
26 Correct 5 ms 212 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 1 ms 316 KB Output is correct
32 Correct 1 ms 212 KB Output is correct
33 Correct 1 ms 212 KB Output is correct
34 Correct 1 ms 212 KB Output is correct
35 Correct 0 ms 212 KB Output is correct
36 Correct 1 ms 212 KB Output is correct
37 Correct 0 ms 212 KB Output is correct
38 Correct 0 ms 212 KB Output is correct
39 Correct 1 ms 340 KB Output is correct
40 Correct 1 ms 340 KB Output is correct
41 Correct 1 ms 212 KB Output is correct
42 Correct 4 ms 340 KB Output is correct
43 Correct 6 ms 468 KB Output is correct
44 Correct 8 ms 332 KB Output is correct
45 Correct 1 ms 212 KB Output is correct
46 Correct 1 ms 212 KB Output is correct
47 Correct 3 ms 340 KB Output is correct
48 Correct 3 ms 444 KB Output is correct
49 Correct 86 ms 416 KB Output is correct
50 Correct 16 ms 340 KB Output is correct
51 Correct 16 ms 360 KB Output is correct
52 Correct 12 ms 340 KB Output is correct
53 Correct 1 ms 212 KB Output is correct
54 Correct 39 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 0 ms 212 KB Output is correct
11 Correct 0 ms 212 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 1 ms 232 KB Output is correct
14 Correct 1 ms 212 KB Output is correct
15 Correct 2 ms 212 KB Output is correct
16 Correct 1 ms 212 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 1 ms 212 KB Output is correct
21 Correct 1 ms 340 KB Output is correct
22 Correct 1 ms 340 KB Output is correct
23 Correct 0 ms 212 KB Output is correct
24 Correct 2 ms 340 KB Output is correct
25 Correct 8 ms 340 KB Output is correct
26 Correct 5 ms 212 KB Output is correct
27 Correct 1 ms 212 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 1 ms 316 KB Output is correct
32 Correct 1 ms 212 KB Output is correct
33 Correct 1 ms 212 KB Output is correct
34 Correct 1 ms 212 KB Output is correct
35 Correct 0 ms 212 KB Output is correct
36 Correct 1 ms 212 KB Output is correct
37 Correct 0 ms 212 KB Output is correct
38 Correct 0 ms 212 KB Output is correct
39 Correct 1 ms 340 KB Output is correct
40 Correct 1 ms 340 KB Output is correct
41 Correct 1 ms 212 KB Output is correct
42 Correct 4 ms 340 KB Output is correct
43 Correct 6 ms 468 KB Output is correct
44 Correct 8 ms 332 KB Output is correct
45 Correct 1 ms 212 KB Output is correct
46 Correct 1 ms 212 KB Output is correct
47 Correct 3 ms 340 KB Output is correct
48 Correct 3 ms 444 KB Output is correct
49 Correct 86 ms 416 KB Output is correct
50 Correct 16 ms 340 KB Output is correct
51 Correct 16 ms 360 KB Output is correct
52 Correct 12 ms 340 KB Output is correct
53 Correct 1 ms 212 KB Output is correct
54 Correct 39 ms 340 KB Output is correct
55 Correct 1 ms 212 KB Output is correct
56 Correct 0 ms 212 KB Output is correct
57 Correct 0 ms 212 KB Output is correct
58 Correct 0 ms 212 KB Output is correct
59 Correct 1 ms 212 KB Output is correct
60 Correct 1 ms 292 KB Output is correct
61 Correct 1 ms 212 KB Output is correct
62 Correct 1 ms 212 KB Output is correct
63 Correct 1 ms 212 KB Output is correct
64 Correct 1 ms 212 KB Output is correct
65 Correct 1 ms 340 KB Output is correct
66 Correct 1 ms 340 KB Output is correct
67 Correct 1 ms 212 KB Output is correct
68 Correct 2 ms 340 KB Output is correct
69 Correct 6 ms 468 KB Output is correct
70 Correct 5 ms 360 KB Output is correct
71 Correct 1 ms 212 KB Output is correct
72 Correct 1 ms 212 KB Output is correct
73 Correct 3 ms 468 KB Output is correct
74 Correct 3 ms 444 KB Output is correct
75 Correct 78 ms 420 KB Output is correct
76 Correct 19 ms 412 KB Output is correct
77 Correct 18 ms 352 KB Output is correct
78 Correct 14 ms 348 KB Output is correct
79 Correct 1 ms 212 KB Output is correct
80 Correct 47 ms 384 KB Output is correct
81 Correct 237 ms 468 KB Output is correct
82 Correct 3895 ms 1620 KB Output is correct
83 Correct 1900 ms 864 KB Output is correct
84 Correct 476 ms 480 KB Output is correct
85 Correct 78 ms 1704 KB Output is correct
86 Correct 71 ms 1708 KB Output is correct
87 Correct 4051 ms 1044 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -