# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
721905 | 2023-04-11T08:41:20 Z | sunnat | Uplifting Excursion (BOI22_vault) | C++14 | 5000 ms | 8276 KB |
#include <algorithm> #include <iostream> #include <vector> #include <queue> #include <cmath> #include <map> #include <set> using namespace std; int main(){ vector<int> dp[2]; int n, m, res = -1; cin >> n >> m; vector<int>a(2*n+1); int q = 505000; for(int i = 0; i < a.size(); i ++) cin >> a[i]; dp[1].resize(2*q+1, -1); dp[1][q] = 0; for(int val = -n; val <= n; val ++){ // cout << val << endl; if(val == 0) continue; dp[0] = dp[1]; int v = val + n; for(int cnt = 1; cnt <= a[v]; cnt ++){ for(int sum = -q; sum <= q; sum ++){ if(dp[1][sum+q] != -1) //if(-q <= sum+val*cnt && sum+val*cnt <= q) dp[0][sum+val*cnt+q] = max(dp[0][sum+val*cnt+q], dp[1][sum+q] + cnt); } } dp[1] = dp[0]; } if(-q<=m && m <= q && dp[1][m+q] != -1) cout << dp[1][m+q] + a[n]; else cout << "impossible"; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 15 ms | 8148 KB | Output is correct |
2 | Correct | 14 ms | 8140 KB | Output is correct |
3 | Correct | 10 ms | 8148 KB | Output is correct |
4 | Correct | 64 ms | 8200 KB | Output is correct |
5 | Correct | 55 ms | 8148 KB | Output is correct |
6 | Correct | 2055 ms | 8196 KB | Output is correct |
7 | Correct | 848 ms | 8196 KB | Output is correct |
8 | Correct | 1922 ms | 8204 KB | Output is correct |
9 | Correct | 3721 ms | 8196 KB | Output is correct |
10 | Correct | 124 ms | 8196 KB | Output is correct |
11 | Correct | 118 ms | 8196 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 15 ms | 8148 KB | Output is correct |
2 | Correct | 14 ms | 8140 KB | Output is correct |
3 | Correct | 10 ms | 8148 KB | Output is correct |
4 | Correct | 64 ms | 8200 KB | Output is correct |
5 | Correct | 55 ms | 8148 KB | Output is correct |
6 | Correct | 2055 ms | 8196 KB | Output is correct |
7 | Correct | 848 ms | 8196 KB | Output is correct |
8 | Correct | 1922 ms | 8204 KB | Output is correct |
9 | Correct | 3721 ms | 8196 KB | Output is correct |
10 | Correct | 124 ms | 8196 KB | Output is correct |
11 | Correct | 118 ms | 8196 KB | Output is correct |
12 | Correct | 17 ms | 8276 KB | Output is correct |
13 | Correct | 13 ms | 8148 KB | Output is correct |
14 | Correct | 9 ms | 8148 KB | Output is correct |
15 | Correct | 56 ms | 8152 KB | Output is correct |
16 | Correct | 69 ms | 8208 KB | Output is correct |
17 | Correct | 2025 ms | 8196 KB | Output is correct |
18 | Correct | 857 ms | 8204 KB | Output is correct |
19 | Correct | 2043 ms | 8204 KB | Output is correct |
20 | Correct | 3642 ms | 8200 KB | Output is correct |
21 | Correct | 170 ms | 8200 KB | Output is correct |
22 | Correct | 121 ms | 8196 KB | Output is correct |
23 | Correct | 116 ms | 8148 KB | Output is correct |
24 | Execution timed out | 5079 ms | 8148 KB | Time limit exceeded |
25 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 59 ms | 8148 KB | Output is correct |
2 | Incorrect | 40 ms | 8204 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 59 ms | 8148 KB | Output is correct |
2 | Incorrect | 40 ms | 8204 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 59 ms | 8148 KB | Output is correct |
2 | Incorrect | 40 ms | 8204 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 15 ms | 8148 KB | Output is correct |
2 | Correct | 14 ms | 8140 KB | Output is correct |
3 | Correct | 10 ms | 8148 KB | Output is correct |
4 | Correct | 64 ms | 8200 KB | Output is correct |
5 | Correct | 55 ms | 8148 KB | Output is correct |
6 | Correct | 2055 ms | 8196 KB | Output is correct |
7 | Correct | 848 ms | 8196 KB | Output is correct |
8 | Correct | 1922 ms | 8204 KB | Output is correct |
9 | Correct | 3721 ms | 8196 KB | Output is correct |
10 | Correct | 124 ms | 8196 KB | Output is correct |
11 | Correct | 118 ms | 8196 KB | Output is correct |
12 | Correct | 59 ms | 8148 KB | Output is correct |
13 | Incorrect | 40 ms | 8204 KB | Output isn't correct |
14 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 59 ms | 8148 KB | Output is correct |
2 | Incorrect | 40 ms | 8204 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 15 ms | 8148 KB | Output is correct |
2 | Correct | 14 ms | 8140 KB | Output is correct |
3 | Correct | 10 ms | 8148 KB | Output is correct |
4 | Correct | 64 ms | 8200 KB | Output is correct |
5 | Correct | 55 ms | 8148 KB | Output is correct |
6 | Correct | 2055 ms | 8196 KB | Output is correct |
7 | Correct | 848 ms | 8196 KB | Output is correct |
8 | Correct | 1922 ms | 8204 KB | Output is correct |
9 | Correct | 3721 ms | 8196 KB | Output is correct |
10 | Correct | 124 ms | 8196 KB | Output is correct |
11 | Correct | 118 ms | 8196 KB | Output is correct |
12 | Correct | 17 ms | 8276 KB | Output is correct |
13 | Correct | 13 ms | 8148 KB | Output is correct |
14 | Correct | 9 ms | 8148 KB | Output is correct |
15 | Correct | 56 ms | 8152 KB | Output is correct |
16 | Correct | 69 ms | 8208 KB | Output is correct |
17 | Correct | 2025 ms | 8196 KB | Output is correct |
18 | Correct | 857 ms | 8204 KB | Output is correct |
19 | Correct | 2043 ms | 8204 KB | Output is correct |
20 | Correct | 3642 ms | 8200 KB | Output is correct |
21 | Correct | 170 ms | 8200 KB | Output is correct |
22 | Correct | 121 ms | 8196 KB | Output is correct |
23 | Correct | 116 ms | 8148 KB | Output is correct |
24 | Execution timed out | 5079 ms | 8148 KB | Time limit exceeded |
25 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 59 ms | 8148 KB | Output is correct |
2 | Incorrect | 40 ms | 8204 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 15 ms | 8148 KB | Output is correct |
2 | Correct | 14 ms | 8140 KB | Output is correct |
3 | Correct | 10 ms | 8148 KB | Output is correct |
4 | Correct | 64 ms | 8200 KB | Output is correct |
5 | Correct | 55 ms | 8148 KB | Output is correct |
6 | Correct | 2055 ms | 8196 KB | Output is correct |
7 | Correct | 848 ms | 8196 KB | Output is correct |
8 | Correct | 1922 ms | 8204 KB | Output is correct |
9 | Correct | 3721 ms | 8196 KB | Output is correct |
10 | Correct | 124 ms | 8196 KB | Output is correct |
11 | Correct | 118 ms | 8196 KB | Output is correct |
12 | Correct | 17 ms | 8276 KB | Output is correct |
13 | Correct | 13 ms | 8148 KB | Output is correct |
14 | Correct | 9 ms | 8148 KB | Output is correct |
15 | Correct | 56 ms | 8152 KB | Output is correct |
16 | Correct | 69 ms | 8208 KB | Output is correct |
17 | Correct | 2025 ms | 8196 KB | Output is correct |
18 | Correct | 857 ms | 8204 KB | Output is correct |
19 | Correct | 2043 ms | 8204 KB | Output is correct |
20 | Correct | 3642 ms | 8200 KB | Output is correct |
21 | Correct | 170 ms | 8200 KB | Output is correct |
22 | Correct | 121 ms | 8196 KB | Output is correct |
23 | Correct | 116 ms | 8148 KB | Output is correct |
24 | Execution timed out | 5079 ms | 8148 KB | Time limit exceeded |
25 | Halted | 0 ms | 0 KB | - |