# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
580332 | 2022-06-21T05:45:46 Z | 반딧불(#8355) | Uplifting Excursion (BOI22_vault) | C++17 | 4949 ms | 2732 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; int n, k; int arr[702]; int DP[2][130002]; int main(){ scanf("%d %d", &n, &k); for(int i=0; i<=n+n; i++) scanf("%d", &arr[i]); if(k < -65000 || k > 65000){ puts("impossible"); return 0; } for(int i=0; i<=130000; i++) DP[0][i] = DP[1][i] = -1e9; DP[1][65000] = 0; vector<ll> vec; for(int i=0; i<=n+n; i++) for(int j=0; j<arr[i]; j++) vec.push_back(i-n); for(int i=0; i<(int)vec.size(); i++){ int b = i%2; for(int j=0; j<=130000; j++) DP[b][j] = -1e9; for(int j=0; j<=130000; j++){ if(DP[!b][j]<0) continue; DP[b][j] = max(DP[b][j], DP[!b][j]); DP[b][j+vec[i]] = max(DP[b][j+vec[i]], DP[!b][j]+1); } } int ans = DP[((int)vec.size()+1)%2][65000+k]; if(ans<=0) printf("impossible"); else printf("%d", ans); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 1236 KB | Output is correct |
2 | Correct | 2 ms | 1236 KB | Output is correct |
3 | Correct | 2 ms | 1236 KB | Output is correct |
4 | Correct | 10 ms | 1236 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 642 ms | 1364 KB | Output is correct |
7 | Correct | 227 ms | 1328 KB | Output is correct |
8 | Correct | 585 ms | 1364 KB | Output is correct |
9 | Correct | 1533 ms | 1400 KB | Output is correct |
10 | Correct | 17 ms | 1236 KB | Output is correct |
11 | Correct | 13 ms | 1320 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 1236 KB | Output is correct |
2 | Correct | 2 ms | 1236 KB | Output is correct |
3 | Correct | 2 ms | 1236 KB | Output is correct |
4 | Correct | 10 ms | 1236 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 642 ms | 1364 KB | Output is correct |
7 | Correct | 227 ms | 1328 KB | Output is correct |
8 | Correct | 585 ms | 1364 KB | Output is correct |
9 | Correct | 1533 ms | 1400 KB | Output is correct |
10 | Correct | 17 ms | 1236 KB | Output is correct |
11 | Correct | 13 ms | 1320 KB | Output is correct |
12 | Correct | 2 ms | 1236 KB | Output is correct |
13 | Correct | 2 ms | 1236 KB | Output is correct |
14 | Correct | 3 ms | 1236 KB | Output is correct |
15 | Correct | 10 ms | 1320 KB | Output is correct |
16 | Correct | 0 ms | 212 KB | Output is correct |
17 | Correct | 656 ms | 1364 KB | Output is correct |
18 | Correct | 214 ms | 1324 KB | Output is correct |
19 | Correct | 589 ms | 1364 KB | Output is correct |
20 | Correct | 1581 ms | 1408 KB | Output is correct |
21 | Correct | 18 ms | 1236 KB | Output is correct |
22 | Correct | 13 ms | 1236 KB | Output is correct |
23 | Correct | 0 ms | 212 KB | Output is correct |
24 | Runtime error | 4949 ms | 2732 KB | Execution killed with signal 11 |
25 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 10 ms | 1236 KB | Output is correct |
2 | Incorrect | 0 ms | 212 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 10 ms | 1236 KB | Output is correct |
2 | Incorrect | 0 ms | 212 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 10 ms | 1236 KB | Output is correct |
2 | Incorrect | 0 ms | 212 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 1236 KB | Output is correct |
2 | Correct | 2 ms | 1236 KB | Output is correct |
3 | Correct | 2 ms | 1236 KB | Output is correct |
4 | Correct | 10 ms | 1236 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 642 ms | 1364 KB | Output is correct |
7 | Correct | 227 ms | 1328 KB | Output is correct |
8 | Correct | 585 ms | 1364 KB | Output is correct |
9 | Correct | 1533 ms | 1400 KB | Output is correct |
10 | Correct | 17 ms | 1236 KB | Output is correct |
11 | Correct | 13 ms | 1320 KB | Output is correct |
12 | Correct | 10 ms | 1236 KB | Output is correct |
13 | Incorrect | 0 ms | 212 KB | Output isn't correct |
14 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 10 ms | 1236 KB | Output is correct |
2 | Incorrect | 0 ms | 212 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 1236 KB | Output is correct |
2 | Correct | 2 ms | 1236 KB | Output is correct |
3 | Correct | 2 ms | 1236 KB | Output is correct |
4 | Correct | 10 ms | 1236 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 642 ms | 1364 KB | Output is correct |
7 | Correct | 227 ms | 1328 KB | Output is correct |
8 | Correct | 585 ms | 1364 KB | Output is correct |
9 | Correct | 1533 ms | 1400 KB | Output is correct |
10 | Correct | 17 ms | 1236 KB | Output is correct |
11 | Correct | 13 ms | 1320 KB | Output is correct |
12 | Correct | 2 ms | 1236 KB | Output is correct |
13 | Correct | 2 ms | 1236 KB | Output is correct |
14 | Correct | 3 ms | 1236 KB | Output is correct |
15 | Correct | 10 ms | 1320 KB | Output is correct |
16 | Correct | 0 ms | 212 KB | Output is correct |
17 | Correct | 656 ms | 1364 KB | Output is correct |
18 | Correct | 214 ms | 1324 KB | Output is correct |
19 | Correct | 589 ms | 1364 KB | Output is correct |
20 | Correct | 1581 ms | 1408 KB | Output is correct |
21 | Correct | 18 ms | 1236 KB | Output is correct |
22 | Correct | 13 ms | 1236 KB | Output is correct |
23 | Correct | 0 ms | 212 KB | Output is correct |
24 | Runtime error | 4949 ms | 2732 KB | Execution killed with signal 11 |
25 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 10 ms | 1236 KB | Output is correct |
2 | Incorrect | 0 ms | 212 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 1236 KB | Output is correct |
2 | Correct | 2 ms | 1236 KB | Output is correct |
3 | Correct | 2 ms | 1236 KB | Output is correct |
4 | Correct | 10 ms | 1236 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 642 ms | 1364 KB | Output is correct |
7 | Correct | 227 ms | 1328 KB | Output is correct |
8 | Correct | 585 ms | 1364 KB | Output is correct |
9 | Correct | 1533 ms | 1400 KB | Output is correct |
10 | Correct | 17 ms | 1236 KB | Output is correct |
11 | Correct | 13 ms | 1320 KB | Output is correct |
12 | Correct | 2 ms | 1236 KB | Output is correct |
13 | Correct | 2 ms | 1236 KB | Output is correct |
14 | Correct | 3 ms | 1236 KB | Output is correct |
15 | Correct | 10 ms | 1320 KB | Output is correct |
16 | Correct | 0 ms | 212 KB | Output is correct |
17 | Correct | 656 ms | 1364 KB | Output is correct |
18 | Correct | 214 ms | 1324 KB | Output is correct |
19 | Correct | 589 ms | 1364 KB | Output is correct |
20 | Correct | 1581 ms | 1408 KB | Output is correct |
21 | Correct | 18 ms | 1236 KB | Output is correct |
22 | Correct | 13 ms | 1236 KB | Output is correct |
23 | Correct | 0 ms | 212 KB | Output is correct |
24 | Runtime error | 4949 ms | 2732 KB | Execution killed with signal 11 |
25 | Halted | 0 ms | 0 KB | - |