# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
580331 | 2022-06-21T05:40:41 Z | 반딧불(#8355) | Uplifting Excursion (BOI22_vault) | C++17 | 149 ms | 468 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; int n, k; int arr[702]; int DP[2][20002]; int main(){ scanf("%d %d", &n, &k); for(int i=0; i<=n+n; i++) scanf("%d", &arr[i]); if(k < -10000 || k > 10000){ puts("impossible"); return 0; } for(int i=0; i<=20000; i++) DP[0][i] = DP[1][i] = -1e9; DP[1][10000] = 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<=20000; j++) DP[b][j] = -1e9; for(int j=0; j<=20000; j++){ if(DP[!b][j]<0) continue; DP[b][j] = max(DP[b][j], DP[!b][j]); if(0 <= j+vec[i] && j+vec[i] <= 20000) DP[b][j+vec[i]] = max(DP[b][j+vec[i]], DP[!b][j]+1); } } int ans = DP[((int)vec.size()+1)%2][10000+k]; if(ans<=0) printf("impossible"); else printf("%d", ans); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Correct | 2 ms | 384 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Incorrect | 149 ms | 468 KB | Output isn't correct |
7 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Correct | 2 ms | 384 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Incorrect | 149 ms | 468 KB | Output isn't correct |
7 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 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 | 1 ms | 340 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 | 1 ms | 340 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 | 1 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Correct | 2 ms | 384 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Incorrect | 149 ms | 468 KB | Output isn't correct |
7 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 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 | 1 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Correct | 2 ms | 384 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Incorrect | 149 ms | 468 KB | Output isn't correct |
7 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 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 | 1 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Correct | 2 ms | 384 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Incorrect | 149 ms | 468 KB | Output isn't correct |
7 | Halted | 0 ms | 0 KB | - |