#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;
}
long long allH = 0;
for (int & x : chefs) {
cin >> x;
allH += x;
}
if (allH < requiredHours) {
cout << "Impossible" << endl;
return 0;
}
int mo = INT_MAX;
for (int mask = 1; mask < (1 << m); mask++){
if (__builtin_popcount(mask) < k) continue;
int orak = 0;
int van = 0;
for (int i = 0; i < m; i++){
if ((1 << i) & mask) {
orak += chefs[i];
van += min(chefs[i], k);
}
}
if (orak < requiredHours) continue;
if (van < k * n) continue;
mo = min(mo, orak - requiredHours);
}
if (mo != INT_MAX) cout << mo << '\n';
else cout << "Impossible" << '\n';
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |