이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |