# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
242182 |
2020-06-27T05:06:32 Z |
oolimry |
Kitchen (BOI19_kitchen) |
C++14 |
|
259 ms |
3168 KB |
#include <bits/stdc++.h>
using namespace std;
void impossible(){ cout << "Impossible"; exit(0); }
const int MAXN = 90005;
bitset<MAXN> dpSmall;
bitset<MAXN> dpBig[305];
vector<int> small, big, smallCan;
int main(){
int n, m, K; cin >> n >> m >> K;
int sumA = 0;
for(int i = 0;i < n;i++){
int a; cin >> a;
sumA += a;
if(a < K) impossible();
}
for(int i = 0;i < m;i++){
int b; cin >> b;
if(b < n) small.push_back(b);
else big.push_back(b);
}
dpSmall[0] = 1;
for(int b : small) dpSmall |= (dpSmall << b);
for(int i = 0;i <= MAXN;i++){
if(dpSmall[i]) smallCan.push_back(i);
}
dpBig[0][0] = 1;
for(int b : big){
for(int i = (int) big.size();i >= 1;i--){
dpBig[i] |= (dpBig[i-1] << b);
}
}
int ans = 102345678;
for(int no = 0;no <= m;no++){
for(int total = 0;total <= MAXN;total++){
if(dpBig[no][total]){
int need = max(sumA - total, (K-no)*n);
auto it = lower_bound(smallCan.begin(),smallCan.end(), need);
if(it == smallCan.end()) continue;
ans = min(ans, *it + total);
}
}
}
if(ans == 102345678) impossible();
cout << ans - sumA;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
416 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Correct |
5 ms |
384 KB |
Output is correct |
8 |
Correct |
6 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
416 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Correct |
5 ms |
384 KB |
Output is correct |
8 |
Correct |
6 ms |
384 KB |
Output is correct |
9 |
Correct |
9 ms |
640 KB |
Output is correct |
10 |
Correct |
7 ms |
564 KB |
Output is correct |
11 |
Correct |
7 ms |
512 KB |
Output is correct |
12 |
Correct |
6 ms |
384 KB |
Output is correct |
13 |
Correct |
6 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
26 ms |
640 KB |
Output is correct |
2 |
Correct |
26 ms |
768 KB |
Output is correct |
3 |
Correct |
31 ms |
768 KB |
Output is correct |
4 |
Correct |
74 ms |
1916 KB |
Output is correct |
5 |
Correct |
35 ms |
1144 KB |
Output is correct |
6 |
Correct |
21 ms |
640 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
18 ms |
768 KB |
Output is correct |
2 |
Correct |
9 ms |
640 KB |
Output is correct |
3 |
Correct |
9 ms |
384 KB |
Output is correct |
4 |
Correct |
9 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
5 ms |
416 KB |
Output is correct |
6 |
Correct |
5 ms |
384 KB |
Output is correct |
7 |
Correct |
5 ms |
384 KB |
Output is correct |
8 |
Correct |
6 ms |
384 KB |
Output is correct |
9 |
Correct |
9 ms |
640 KB |
Output is correct |
10 |
Correct |
7 ms |
564 KB |
Output is correct |
11 |
Correct |
7 ms |
512 KB |
Output is correct |
12 |
Correct |
6 ms |
384 KB |
Output is correct |
13 |
Correct |
6 ms |
384 KB |
Output is correct |
14 |
Correct |
26 ms |
640 KB |
Output is correct |
15 |
Correct |
26 ms |
768 KB |
Output is correct |
16 |
Correct |
31 ms |
768 KB |
Output is correct |
17 |
Correct |
74 ms |
1916 KB |
Output is correct |
18 |
Correct |
35 ms |
1144 KB |
Output is correct |
19 |
Correct |
21 ms |
640 KB |
Output is correct |
20 |
Correct |
18 ms |
768 KB |
Output is correct |
21 |
Correct |
9 ms |
640 KB |
Output is correct |
22 |
Correct |
9 ms |
384 KB |
Output is correct |
23 |
Correct |
9 ms |
384 KB |
Output is correct |
24 |
Correct |
5 ms |
384 KB |
Output is correct |
25 |
Correct |
180 ms |
2560 KB |
Output is correct |
26 |
Correct |
230 ms |
3040 KB |
Output is correct |
27 |
Correct |
57 ms |
1516 KB |
Output is correct |
28 |
Correct |
118 ms |
2048 KB |
Output is correct |
29 |
Correct |
259 ms |
3168 KB |
Output is correct |
30 |
Correct |
127 ms |
2300 KB |
Output is correct |