# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
964599 | 2024-04-17T07:37:17 Z | aeg | Uplifting Excursion (BOI22_vault) | C++17 | 2505 ms | 8284 KB |
#include <bits/stdc++.h> using namespace std; #define int long long int OFFSET, OFFSET_SUM; int dp[2][250005]; signed main() { int n, l; cin >> n >> l; vector<int> v(2 * n + 1); for (auto& i : v) cin >> i; OFFSET = n, OFFSET_SUM = n * 50 * 50; if (l > OFFSET_SUM || l < -OFFSET_SUM) { cout << "impossible"; return 0; } for (int i = 0; i <= 2 * OFFSET_SUM; ++i) dp[0][i] = dp[1][i] = -1e9; dp[1][OFFSET_SUM] = 0; for (int i = 0; i <= 2 * n; ++i) { int actual_value = i - OFFSET; for (int j = 0; j <= OFFSET_SUM * 2; ++j) { dp[i & 1][j] = max(dp[i & 1][j], dp[i & 1 ^ 1][j]); for (int k = 1; k <= v[i]; ++k) { int prev_sum = j - k * actual_value; if (prev_sum < 0 || prev_sum > OFFSET_SUM * 2) continue; dp[i & 1][j] = max(dp[i & 1][j], dp[i & 1 ^ 1][prev_sum] + k); } } } int ans = dp[0][OFFSET_SUM + l]; if (ans <= 0) cout << "impossible"; else cout << ans; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2392 KB | Output is correct |
2 | Correct | 1 ms | 2396 KB | Output is correct |
3 | Correct | 1 ms | 2392 KB | Output is correct |
4 | Correct | 5 ms | 2648 KB | Output is correct |
5 | Correct | 1 ms | 348 KB | Output is correct |
6 | Correct | 1404 ms | 4324 KB | Output is correct |
7 | Correct | 374 ms | 4436 KB | Output is correct |
8 | Correct | 1071 ms | 4324 KB | Output is correct |
9 | Correct | 2369 ms | 4328 KB | Output is correct |
10 | Correct | 70 ms | 4328 KB | Output is correct |
11 | Correct | 47 ms | 4184 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2392 KB | Output is correct |
2 | Correct | 1 ms | 2396 KB | Output is correct |
3 | Correct | 1 ms | 2392 KB | Output is correct |
4 | Correct | 5 ms | 2648 KB | Output is correct |
5 | Correct | 1 ms | 348 KB | Output is correct |
6 | Correct | 1404 ms | 4324 KB | Output is correct |
7 | Correct | 374 ms | 4436 KB | Output is correct |
8 | Correct | 1071 ms | 4324 KB | Output is correct |
9 | Correct | 2369 ms | 4328 KB | Output is correct |
10 | Correct | 70 ms | 4328 KB | Output is correct |
11 | Correct | 47 ms | 4184 KB | Output is correct |
12 | Correct | 1 ms | 2392 KB | Output is correct |
13 | Correct | 1 ms | 2492 KB | Output is correct |
14 | Correct | 1 ms | 2396 KB | Output is correct |
15 | Correct | 5 ms | 2652 KB | Output is correct |
16 | Correct | 1 ms | 348 KB | Output is correct |
17 | Correct | 1355 ms | 4324 KB | Output is correct |
18 | Correct | 372 ms | 4328 KB | Output is correct |
19 | Correct | 1195 ms | 4328 KB | Output is correct |
20 | Correct | 2505 ms | 4324 KB | Output is correct |
21 | Correct | 54 ms | 4328 KB | Output is correct |
22 | Correct | 52 ms | 4584 KB | Output is correct |
23 | Correct | 1 ms | 344 KB | Output is correct |
24 | Runtime error | 5 ms | 8284 KB | Execution killed with signal 11 |
25 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 2648 KB | Output is correct |
2 | Incorrect | 1 ms | 348 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 2648 KB | Output is correct |
2 | Incorrect | 1 ms | 348 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 2648 KB | Output is correct |
2 | Incorrect | 1 ms | 348 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2392 KB | Output is correct |
2 | Correct | 1 ms | 2396 KB | Output is correct |
3 | Correct | 1 ms | 2392 KB | Output is correct |
4 | Correct | 5 ms | 2648 KB | Output is correct |
5 | Correct | 1 ms | 348 KB | Output is correct |
6 | Correct | 1404 ms | 4324 KB | Output is correct |
7 | Correct | 374 ms | 4436 KB | Output is correct |
8 | Correct | 1071 ms | 4324 KB | Output is correct |
9 | Correct | 2369 ms | 4328 KB | Output is correct |
10 | Correct | 70 ms | 4328 KB | Output is correct |
11 | Correct | 47 ms | 4184 KB | Output is correct |
12 | Correct | 5 ms | 2648 KB | Output is correct |
13 | Incorrect | 1 ms | 348 KB | Output isn't correct |
14 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 2648 KB | Output is correct |
2 | Incorrect | 1 ms | 348 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2392 KB | Output is correct |
2 | Correct | 1 ms | 2396 KB | Output is correct |
3 | Correct | 1 ms | 2392 KB | Output is correct |
4 | Correct | 5 ms | 2648 KB | Output is correct |
5 | Correct | 1 ms | 348 KB | Output is correct |
6 | Correct | 1404 ms | 4324 KB | Output is correct |
7 | Correct | 374 ms | 4436 KB | Output is correct |
8 | Correct | 1071 ms | 4324 KB | Output is correct |
9 | Correct | 2369 ms | 4328 KB | Output is correct |
10 | Correct | 70 ms | 4328 KB | Output is correct |
11 | Correct | 47 ms | 4184 KB | Output is correct |
12 | Correct | 1 ms | 2392 KB | Output is correct |
13 | Correct | 1 ms | 2492 KB | Output is correct |
14 | Correct | 1 ms | 2396 KB | Output is correct |
15 | Correct | 5 ms | 2652 KB | Output is correct |
16 | Correct | 1 ms | 348 KB | Output is correct |
17 | Correct | 1355 ms | 4324 KB | Output is correct |
18 | Correct | 372 ms | 4328 KB | Output is correct |
19 | Correct | 1195 ms | 4328 KB | Output is correct |
20 | Correct | 2505 ms | 4324 KB | Output is correct |
21 | Correct | 54 ms | 4328 KB | Output is correct |
22 | Correct | 52 ms | 4584 KB | Output is correct |
23 | Correct | 1 ms | 344 KB | Output is correct |
24 | Runtime error | 5 ms | 8284 KB | Execution killed with signal 11 |
25 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 2648 KB | Output is correct |
2 | Incorrect | 1 ms | 348 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 2392 KB | Output is correct |
2 | Correct | 1 ms | 2396 KB | Output is correct |
3 | Correct | 1 ms | 2392 KB | Output is correct |
4 | Correct | 5 ms | 2648 KB | Output is correct |
5 | Correct | 1 ms | 348 KB | Output is correct |
6 | Correct | 1404 ms | 4324 KB | Output is correct |
7 | Correct | 374 ms | 4436 KB | Output is correct |
8 | Correct | 1071 ms | 4324 KB | Output is correct |
9 | Correct | 2369 ms | 4328 KB | Output is correct |
10 | Correct | 70 ms | 4328 KB | Output is correct |
11 | Correct | 47 ms | 4184 KB | Output is correct |
12 | Correct | 1 ms | 2392 KB | Output is correct |
13 | Correct | 1 ms | 2492 KB | Output is correct |
14 | Correct | 1 ms | 2396 KB | Output is correct |
15 | Correct | 5 ms | 2652 KB | Output is correct |
16 | Correct | 1 ms | 348 KB | Output is correct |
17 | Correct | 1355 ms | 4324 KB | Output is correct |
18 | Correct | 372 ms | 4328 KB | Output is correct |
19 | Correct | 1195 ms | 4328 KB | Output is correct |
20 | Correct | 2505 ms | 4324 KB | Output is correct |
21 | Correct | 54 ms | 4328 KB | Output is correct |
22 | Correct | 52 ms | 4584 KB | Output is correct |
23 | Correct | 1 ms | 344 KB | Output is correct |
24 | Runtime error | 5 ms | 8284 KB | Execution killed with signal 11 |
25 | Halted | 0 ms | 0 KB | - |