# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
522787 | LucaDantas | Kitchen (BOI19_kitchen) | C++17 | 1 ms | 204 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <cstdio>
#include <algorithm>
using namespace std;
constexpr int maxn = 310, inf = 0x3f3f3f3f;
int a[maxn], b[maxn], ex[maxn];
int dp[maxn*maxn];
int main() {
int n, m, k, soma = 0; scanf("%d %d %d", &n, &m, &k);
for(int i = 0; i < n; i++) {
scanf("%d", a+i), soma += a[i];
if(a[i] < k) return puts("impossible"), 0;
}
for(int i = 0; i < m; i++)
scanf("%d", b+i);
int ans = inf;
for(int mask = 0; mask < (1 << m); mask++) {
int tot = 0, bom = 0;
for(int i = 0; i < m; i++)
if(mask & (1 << i)) tot += b[i], bom += min(n, b[i]);
if(tot >= soma && bom >= n*k) ans = min(ans, tot);
}
if(ans == inf) puts("impossible");
else printf("%d\n", ans-soma);
}
Compilation message (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... |