#include <iostream>
using namespace std;
int N, M, K;
int A[310], B[310];
int ans, numChef, totHour, totDish, total;
int main()
{
cin >> N >> M >> K;
for(int i=1; i<=N; i++) {
cin >> A[i];
total += A[i];
if (A[i] < K) {
cout << "Impossible" << endl;
return 0;
}
}
for(int i=1; i<=M; i++) cin >> B[i];
ans = 1e9;
for(int i=0; i<(1<<M); i++) { // i=biner
numChef = 0;
totHour = 0;
totDish = 0;
for(int j=0; j<M; j++) { // j=digit ke
if (i&(1<<j)) {
numChef++;
totHour += B[j+1];
totDish += min(B[j+1], N);
}
}
if (totHour >= total && totDish >= N*K) {
ans = min(ans, totHour-total);
}
}
if (ans==1e9) cout << "Impossible" << endl;
else cout << ans << endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
256 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
300 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
300 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
256 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
300 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
300 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
3 ms |
212 KB |
Output is correct |
10 |
Correct |
2 ms |
212 KB |
Output is correct |
11 |
Correct |
2 ms |
212 KB |
Output is correct |
12 |
Correct |
2 ms |
212 KB |
Output is correct |
13 |
Correct |
3 ms |
304 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
304 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 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
256 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
300 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
300 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
3 ms |
212 KB |
Output is correct |
10 |
Correct |
2 ms |
212 KB |
Output is correct |
11 |
Correct |
2 ms |
212 KB |
Output is correct |
12 |
Correct |
2 ms |
212 KB |
Output is correct |
13 |
Correct |
3 ms |
304 KB |
Output is correct |
14 |
Incorrect |
1 ms |
304 KB |
Output isn't correct |
15 |
Halted |
0 ms |
0 KB |
- |