# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
745941 |
2023-05-21T09:50:51 Z |
vjudge1 |
Kitchen (BOI19_kitchen) |
C++14 |
|
1000 ms |
304 KB |
#include<bits/stdc++.h>
using namespace std;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
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" << '\n';
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 << '\n';
else cout << "Impossible" << '\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 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 |
0 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 |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 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 |
0 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 |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
43 ms |
212 KB |
Output is correct |
10 |
Correct |
69 ms |
296 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
415 ms |
296 KB |
Output is correct |
13 |
Execution timed out |
1067 ms |
212 KB |
Time limit exceeded |
14 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
21 ms |
304 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 |
0 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 |
0 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 |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
43 ms |
212 KB |
Output is correct |
10 |
Correct |
69 ms |
296 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
415 ms |
296 KB |
Output is correct |
13 |
Execution timed out |
1067 ms |
212 KB |
Time limit exceeded |
14 |
Halted |
0 ms |
0 KB |
- |