# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
522788 | 2022-02-05T19:49:40 Z | LucaDantas | Kitchen (BOI19_kitchen) | C++17 | 28 ms | 716 KB |
#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
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 588 KB | Output is correct |
2 | Correct | 1 ms | 588 KB | Output is correct |
3 | Correct | 2 ms | 716 KB | Output is correct |
4 | Correct | 1 ms | 588 KB | Output is correct |
5 | Correct | 1 ms | 588 KB | Output is correct |
6 | Correct | 0 ms | 204 KB | Output is correct |
7 | Correct | 1 ms | 204 KB | Output is correct |
8 | Correct | 1 ms | 588 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 588 KB | Output is correct |
2 | Correct | 1 ms | 588 KB | Output is correct |
3 | Correct | 2 ms | 716 KB | Output is correct |
4 | Correct | 1 ms | 588 KB | Output is correct |
5 | Correct | 1 ms | 588 KB | Output is correct |
6 | Correct | 0 ms | 204 KB | Output is correct |
7 | Correct | 1 ms | 204 KB | Output is correct |
8 | Correct | 1 ms | 588 KB | Output is correct |
9 | Correct | 2 ms | 588 KB | Output is correct |
10 | Correct | 2 ms | 588 KB | Output is correct |
11 | Correct | 2 ms | 536 KB | Output is correct |
12 | Correct | 2 ms | 588 KB | Output is correct |
13 | Correct | 2 ms | 536 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 20 ms | 588 KB | Output is correct |
2 | Correct | 19 ms | 588 KB | Output is correct |
3 | Correct | 23 ms | 588 KB | Output is correct |
4 | Correct | 25 ms | 636 KB | Output is correct |
5 | Correct | 25 ms | 588 KB | Output is correct |
6 | Correct | 28 ms | 588 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 588 KB | Output is correct |
2 | Correct | 5 ms | 588 KB | Output is correct |
3 | Correct | 4 ms | 588 KB | Output is correct |
4 | Correct | 4 ms | 652 KB | Output is correct |
5 | Correct | 0 ms | 204 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 588 KB | Output is correct |
2 | Correct | 1 ms | 588 KB | Output is correct |
3 | Correct | 2 ms | 716 KB | Output is correct |
4 | Correct | 1 ms | 588 KB | Output is correct |
5 | Correct | 1 ms | 588 KB | Output is correct |
6 | Correct | 0 ms | 204 KB | Output is correct |
7 | Correct | 1 ms | 204 KB | Output is correct |
8 | Correct | 1 ms | 588 KB | Output is correct |
9 | Correct | 2 ms | 588 KB | Output is correct |
10 | Correct | 2 ms | 588 KB | Output is correct |
11 | Correct | 2 ms | 536 KB | Output is correct |
12 | Correct | 2 ms | 588 KB | Output is correct |
13 | Correct | 2 ms | 536 KB | Output is correct |
14 | Correct | 20 ms | 588 KB | Output is correct |
15 | Correct | 19 ms | 588 KB | Output is correct |
16 | Correct | 23 ms | 588 KB | Output is correct |
17 | Correct | 25 ms | 636 KB | Output is correct |
18 | Correct | 25 ms | 588 KB | Output is correct |
19 | Correct | 28 ms | 588 KB | Output is correct |
20 | Correct | 4 ms | 588 KB | Output is correct |
21 | Correct | 5 ms | 588 KB | Output is correct |
22 | Correct | 4 ms | 588 KB | Output is correct |
23 | Correct | 4 ms | 652 KB | Output is correct |
24 | Correct | 0 ms | 204 KB | Output is correct |
25 | Correct | 17 ms | 540 KB | Output is correct |
26 | Correct | 19 ms | 588 KB | Output is correct |
27 | Correct | 13 ms | 588 KB | Output is correct |
28 | Correct | 22 ms | 540 KB | Output is correct |
29 | Correct | 21 ms | 660 KB | Output is correct |
30 | Correct | 24 ms | 652 KB | Output is correct |