# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
160603 | luciocf | Kitchen (BOI19_kitchen) | C++14 | 43 ms | 760 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 <bits/stdc++.h>
using namespace std;
const int maxn = 310;
const int maxs = 9e4+10;
const int inf = 1e9+10;
int n, m, k, tot;
int a[maxn], b[maxn];
int dp[maxs];
int main(void)
{
scanf("%d %d %d", &n, &m, &k);
for (int i = 1; i <= n; i++)
{
scanf("%d", &a[i]);
tot += a[i];
}
for (int i = 1; i <= m; i++)
scanf("%d", &b[i]);
for (int i = 1; i <= n; i++)
{
if (a[i] < k)
{
printf("Impossible\n");
return 0;
}
}
for (int i = 1; i < maxs; i++)
dp[i] = -inf;
for (int i = 1; i <= m; i++)
for (int j = maxs-1; j >= b[i]; j--)
dp[j] = max(dp[j], dp[j-b[i]]+min(b[i], n));
int ans = -1;
for (int i = tot; i < maxs; i++)
{
if (dp[i] >= n*k)
{
ans = i;
break;
}
}
if (ans == -1) printf("Impossible\n");
else printf("%d\n", ans-tot);
}
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... |