# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
522782 | LucaDantas | Kitchen (BOI19_kitchen) | C++17 | 25 ms | 656 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>
constexpr int maxn = 310, inf = 0x3f3f3f3f;
int a[maxn], b[maxn];
int dp[maxn*maxn];
int main() {
int n, m, k; scanf("%d %d %d", &n, &m, &k);
for(int i = 0; i < n; i++)
scanf("%d", a+i);
for(int i = 0; i < m; i++)
scanf("%d", b+i);
int soma = 0;
for(int i = 0; i < n; i++) {
soma += a[i];
if(a[i] < k) return puts("impossible"), 0;
}
auto max = [](int a, int b) { return a > b ? a : b; };
auto min = [](int a, int b) { return a < b ? a : b; };
for(int i = 0; i < maxn*maxn; i++)
dp[i] = -inf;
dp[0] = 0;
for(int i = 0; i < m; i++)
for(int j = maxn*maxn - 1 - b[i]; j >= 0; j--)
dp[j+b[i]] = max(dp[j+b[i]], dp[j] + min(n, b[i]));
for(int j = soma; j < maxn*maxn; j++)
if(dp[j] >= n*k) return printf("%d\n", j-soma), 0;
puts("impossible");
}
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... |