# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
746029 |
2023-05-21T10:40:09 Z |
vjudge1 |
Kitchen (BOI19_kitchen) |
C++14 |
|
29 ms |
300 KB |
#include <bits/stdc++.h>
using namespace std;
int main(){
int n, m, k;
cin >> n >> m >> k;
vector<int> a(n), b(m);
int csum = 0, mmm = k;
for(int i = 0; i < n; i++){
cin >> a[i];
csum += a[i];
mmm = min(mmm, a[i]);
}
for(int i = 0; i < m; i++){
cin >> b[i];
}
if(mmm < k){
cout << "Impossible\n";
return 0;
}
int ans = INT_MAX;
int ketto[20];
ketto[0] = 1;
for(int i = 1; i < 20; i++){
ketto[i] = 2 * ketto[i - 1];
}
for(int i = 0; i < ketto[m]; i++){
int sum = 0;
for(int j = 0; j < m; j++){
if(ketto[j] & i){
sum += b[j];
}
}
if(csum > sum){
continue;
}
priority_queue<int> pq;
for(int j = 0; j < m; j++){
if(ketto[j] & i){
pq.push(b[j]);
}
}
int n1 = n;
vector<int> vf;
int errar = false;
while(n1--){
int k1 = k;
vf.clear();
while(k1--){
if(pq.size() > 0 && pq.top() > 0){
vf.push_back(pq.top() - 1);
pq.pop();
}
else{
errar = true;
}
}
for(int e : vf){
if(e > 0){
pq.push(e);
}
}
}
if(!errar){
ans = min(ans, sum - csum);
continue;
}
}
if(ans != INT_MAX)
cout << ans << endl;
else cout << "Impossible\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
29 ms |
296 KB |
Output is correct |
10 |
Correct |
26 ms |
276 KB |
Output is correct |
11 |
Correct |
3 ms |
300 KB |
Output is correct |
12 |
Correct |
4 ms |
212 KB |
Output is correct |
13 |
Correct |
22 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
29 ms |
296 KB |
Output is correct |
10 |
Correct |
26 ms |
276 KB |
Output is correct |
11 |
Correct |
3 ms |
300 KB |
Output is correct |
12 |
Correct |
4 ms |
212 KB |
Output is correct |
13 |
Correct |
22 ms |
212 KB |
Output is correct |
14 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
15 |
Halted |
0 ms |
0 KB |
- |