# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
402647 | 2021-05-12T07:51:29 Z | Nicholas_Patrick | Kitchen (BOI19_kitchen) | C++17 | 130 ms | 13544 KB |
#include <cstdio> #include <queue> #include <bitset> #include <algorithm> using namespace std; const int maxall=300; const int maxrow=maxall*maxall+1; int main(){ int n, m, k; scanf("%d%d%d", &n, &m, &k); vector<int> a(n), b(m); int A=0; for(int& i: a){ scanf("%d", &i); A+=i; } for(int& i: b) scanf("%d", &i); if(*min_element(a.begin(), a.end())<k){ printf("Impossible\n"); return 0; } sort(b.begin(), b.end()); auto it=upper_bound(b.begin(), b.end(), n); bitset<maxrow> smallsums; smallsums[0]=true; for(auto i=b.begin(); i!=it; i++) smallsums|=smallsums<<*i; bitset<maxrow*(maxall+1)> mask; for(int i=0; i<maxrow; i++) mask[i+maxrow*min(i/n, maxall)]=smallsums[i]; //bottleneck for(auto i=it; i!=b.end(); i++) mask|=mask<<(maxrow+*i)|mask<<*i; for(int i=A; i<maxrow; i++){ if(mask[i+k*maxrow]){ printf("%d\n", i-A); return 0; } } printf("Impossible\n"); }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 15 ms | 13544 KB | Output is correct |
2 | Correct | 16 ms | 13516 KB | Output is correct |
3 | Correct | 16 ms | 13544 KB | Output is correct |
4 | Correct | 15 ms | 13540 KB | Output is correct |
5 | Correct | 8 ms | 13544 KB | Output is correct |
6 | Correct | 7 ms | 13428 KB | Output is correct |
7 | Correct | 7 ms | 13516 KB | Output is correct |
8 | Correct | 14 ms | 13516 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 15 ms | 13544 KB | Output is correct |
2 | Correct | 16 ms | 13516 KB | Output is correct |
3 | Correct | 16 ms | 13544 KB | Output is correct |
4 | Correct | 15 ms | 13540 KB | Output is correct |
5 | Correct | 8 ms | 13544 KB | Output is correct |
6 | Correct | 7 ms | 13428 KB | Output is correct |
7 | Correct | 7 ms | 13516 KB | Output is correct |
8 | Correct | 14 ms | 13516 KB | Output is correct |
9 | Correct | 58 ms | 13528 KB | Output is correct |
10 | Correct | 60 ms | 13516 KB | Output is correct |
11 | Correct | 36 ms | 13536 KB | Output is correct |
12 | Incorrect | 8 ms | 13516 KB | Output isn't correct |
13 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 9 ms | 13516 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 130 ms | 13520 KB | Output is correct |
2 | Correct | 77 ms | 13532 KB | Output is correct |
3 | Incorrect | 10 ms | 13536 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 15 ms | 13544 KB | Output is correct |
2 | Correct | 16 ms | 13516 KB | Output is correct |
3 | Correct | 16 ms | 13544 KB | Output is correct |
4 | Correct | 15 ms | 13540 KB | Output is correct |
5 | Correct | 8 ms | 13544 KB | Output is correct |
6 | Correct | 7 ms | 13428 KB | Output is correct |
7 | Correct | 7 ms | 13516 KB | Output is correct |
8 | Correct | 14 ms | 13516 KB | Output is correct |
9 | Correct | 58 ms | 13528 KB | Output is correct |
10 | Correct | 60 ms | 13516 KB | Output is correct |
11 | Correct | 36 ms | 13536 KB | Output is correct |
12 | Incorrect | 8 ms | 13516 KB | Output isn't correct |
13 | Halted | 0 ms | 0 KB | - |