# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
546202 | 2022-04-06T16:03:51 Z | MilosMilutinovic | Kitchen (BOI19_kitchen) | C++ | 91 ms | 105940 KB |
#include <stdio.h> #define N 300 #define N_ 90000 #define INF 0x3f3f3f int min(int a, int b) { return a < b ? a : b; } int max(int a, int b) { return a > b ? a : b; } int main() { static int aa[N], bb[N], dp[N][N_]; int n, m, k, i, j, s, mn; scanf("%d%d%d", &n, &m, &k); for (i = 0, s = 0; i < n; i++) scanf("%d", &aa[i]), s += aa[i]; for (i = 0; i < m; i++) scanf("%d", &bb[i]); mn = aa[0]; for (i = 1; i < n; i++) mn = min(mn, aa[i]); if (mn < k) { printf("Impossible"); return 0; } for (i = 0; i < m; i++) for (j = 0; j < N_; j++) dp[i][j] = -INF; dp[0][0] = 0; dp[0][bb[0]] = min(n, bb[0]); for (i = 1; i < m; i++) for (j = 0; j < N_; j++) dp[i][j] = max(dp[i - 1][j], (bb[i] <= j ? dp[i - 1][j - bb[i]] + min(n, bb[i]) : -INF)); int ans = -1; for (i = N_ - 1; i >= s; i--) if (dp[m - 1][i] >= n * k) ans = i - s; if (ans == -1) printf("Impossible"); else printf("%d", ans); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 980 KB | Output is correct |
2 | Correct | 1 ms | 980 KB | Output is correct |
3 | Correct | 1 ms | 980 KB | Output is correct |
4 | Correct | 1 ms | 980 KB | Output is correct |
5 | Correct | 1 ms | 980 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 2 ms | 980 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 980 KB | Output is correct |
2 | Correct | 1 ms | 980 KB | Output is correct |
3 | Correct | 1 ms | 980 KB | Output is correct |
4 | Correct | 1 ms | 980 KB | Output is correct |
5 | Correct | 1 ms | 980 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 2 ms | 980 KB | Output is correct |
9 | Correct | 4 ms | 5580 KB | Output is correct |
10 | Correct | 4 ms | 5460 KB | Output is correct |
11 | Correct | 5 ms | 5460 KB | Output is correct |
12 | Correct | 5 ms | 5460 KB | Output is correct |
13 | Correct | 5 ms | 5560 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 76 ms | 92136 KB | Output is correct |
2 | Correct | 61 ms | 79884 KB | Output is correct |
3 | Correct | 82 ms | 105940 KB | Output is correct |
4 | Correct | 86 ms | 105932 KB | Output is correct |
5 | Correct | 91 ms | 102476 KB | Output is correct |
6 | Correct | 57 ms | 73528 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 14 ms | 14356 KB | Output is correct |
2 | Correct | 12 ms | 14376 KB | Output is correct |
3 | Correct | 12 ms | 14292 KB | Output is correct |
4 | Correct | 12 ms | 14284 KB | Output is correct |
5 | Correct | 0 ms | 296 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 980 KB | Output is correct |
2 | Correct | 1 ms | 980 KB | Output is correct |
3 | Correct | 1 ms | 980 KB | Output is correct |
4 | Correct | 1 ms | 980 KB | Output is correct |
5 | Correct | 1 ms | 980 KB | Output is correct |
6 | Correct | 0 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 2 ms | 980 KB | Output is correct |
9 | Correct | 4 ms | 5580 KB | Output is correct |
10 | Correct | 4 ms | 5460 KB | Output is correct |
11 | Correct | 5 ms | 5460 KB | Output is correct |
12 | Correct | 5 ms | 5460 KB | Output is correct |
13 | Correct | 5 ms | 5560 KB | Output is correct |
14 | Correct | 76 ms | 92136 KB | Output is correct |
15 | Correct | 61 ms | 79884 KB | Output is correct |
16 | Correct | 82 ms | 105940 KB | Output is correct |
17 | Correct | 86 ms | 105932 KB | Output is correct |
18 | Correct | 91 ms | 102476 KB | Output is correct |
19 | Correct | 57 ms | 73528 KB | Output is correct |
20 | Correct | 14 ms | 14356 KB | Output is correct |
21 | Correct | 12 ms | 14376 KB | Output is correct |
22 | Correct | 12 ms | 14292 KB | Output is correct |
23 | Correct | 12 ms | 14284 KB | Output is correct |
24 | Correct | 0 ms | 296 KB | Output is correct |
25 | Correct | 76 ms | 74208 KB | Output is correct |
26 | Correct | 74 ms | 85868 KB | Output is correct |
27 | Correct | 44 ms | 56524 KB | Output is correct |
28 | Correct | 74 ms | 86136 KB | Output is correct |
29 | Correct | 74 ms | 88340 KB | Output is correct |
30 | Correct | 86 ms | 105852 KB | Output is correct |