# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
125561 | eriksuenderhauf | Kitchen (BOI19_kitchen) | C++11 | 32 ms | 636 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>
int a[301], b[301], dp[301*301], n, m, k, sm = 0;
int main() {
scanf("%d %d %d", &n, &m, &k), dp[0] = 1;
for (int i = 1; i <= n; i++) scanf("%d", &a[i]), sm += a[i];
for (int i = 1; i <= m; i++) scanf("%d", &b[i]);
if (*std::min_element(a+1,a+n+1) < k || m < k) return !printf("Impossible\n");
for (int i = 1; i <= m; i++) for (int j = 301*301-1; j >= b[i]; j--) if (dp[j-b[i]] > 0) dp[j] = std::max(dp[j], dp[j-b[i]] + std::min(b[i],n));
for (int j = sm; j < 301*301; j++) if (dp[j] > n*k) return !printf("%d\n", j-sm);
return !printf("Impossible\n");
}
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... |