# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
525552 | Yazan_Alattar | Kitchen (BOI19_kitchen) | C++14 | 79 ms | 296 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pb push_back
#define endl "\n"
#define all(x) x.begin(), x.end()
const int M = 3005;
const ll inf = 1e9;
const ll mod = 998244353;
const double pi = acos(-1);
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
int n, m, k, a[M], b[M], sum, tot, cnt[M], ans = inf;
int main()
{
scanf("%d%d%d", &n, &m, &k);
for(int i = 1; i <= n; ++i) {
scanf("%d", &a[i]);
sum += a[i];
if(a[i] < k) printf("Impossible\n"), exit(0);
}
for(int i = 1; i <= m; ++i) scanf("%d", &b[i]), tot += b[i];
if(sum > tot) printf("Impossible\n"), exit(0);
for(int mask = 0; mask < (1 << m); ++mask){
for(int i = 1; i <= n; ++i) cnt[i] = 0;
int res = 0;
for(int i = 1; i <= m; ++i) if((mask >> (i - 1)) & 1){
res += b[i];
int rem = b[i];
for(int j = 1; j <= n; ++j) if(rem && cnt[j] < k) ++cnt[j], --rem;
}
bool ok = (res >= sum);
for(int i = 1; i <= n; ++i) ok &= (cnt[i] >= k);
if(ok) ans = min(ans, res - sum);
}
if(ans == inf) printf("Impossible\n");
else printf("%d\n", ans);
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | 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... |