# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
745936 |
2023-05-21T09:48:33 Z |
vjudge1 |
Kitchen (BOI19_kitchen) |
C++14 |
|
1000 ms |
332 KB |
#include<bits/stdc++.h>
using namespace std;
int main(){
int n, m, k, requiredHours = 0;
cin >> n >> m >> k;
vector<int> meals(n), chefs(m);
for (int & x : meals) {
cin >> x;
if (x < k){
cout << "Impossible" << endl;
return 0;
}
requiredHours += x;
}
for (int & x : chefs) cin >> x;
int mo = INT_MAX;
for (int mask = 1; mask < (1 << m); mask++){
if (__builtin_popcount(mask) < k) continue;
int orak = 0;
set<pair<int, int> > tud, tud2;
for (int i = 0; i < m; i++){
if ((1 << i) & mask) {
orak += chefs[i];
tud.insert(make_pair(chefs[i], i));
}
}
bool jo = true;
for (int i = 0; i < n; i++){
for (int j = 0; j < k; j++){
if (tud.size() == 0){
jo = false;
break;
}
if ((*tud.rbegin()).first != 1){
tud2.insert(make_pair((*tud.rbegin()).first - 1, (*tud.rbegin()).second));
}
tud.erase(*tud.rbegin());
}
if (jo == false) break;
while(!tud.empty()){
tud2.insert(*tud.rbegin());
tud.erase(*tud.rbegin());
}
swap(tud, tud2);
}
if (jo == false) continue;
if (requiredHours <= orak) mo = min(mo, orak - requiredHours);
}
if (mo != INT_MAX) cout << mo << endl;
else cout << "Impossible" << endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 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 |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 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 |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
31 ms |
212 KB |
Output is correct |
10 |
Correct |
66 ms |
276 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
377 ms |
332 KB |
Output is correct |
13 |
Execution timed out |
1075 ms |
212 KB |
Time limit exceeded |
14 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
19 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 |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 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 |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
31 ms |
212 KB |
Output is correct |
10 |
Correct |
66 ms |
276 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
377 ms |
332 KB |
Output is correct |
13 |
Execution timed out |
1075 ms |
212 KB |
Time limit exceeded |
14 |
Halted |
0 ms |
0 KB |
- |