# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
227947 | 2020-04-29T09:53:07 Z | PeppaPig | Kitchen (BOI19_kitchen) | C++14 | 46 ms | 1072 KB |
#include <bits/stdc++.h> using namespace std; const int N = 305; int n, m, k, sum; int A[N], B[N], dp[2][N * N]; int main() { scanf("%d %d %d", &n, &m, &k); if(m < k) return !printf("Impossible\n"); for(int i = 1; i <= n; i++) { scanf("%d", A + i), sum += A[i]; if(A[i] < k) return !printf("Impossible\n"); } for(int i = 1; i <= m; i++) scanf("%d", B + i); for(int i = 1; i < N * N; i++) dp[0][i] = -1e9; for(int i = 1; i <= m; i++) { int now = i & 1, pre = now ^ 1; for(int j = 0; j < N * N; j++) { dp[now][j] = dp[pre][j]; if(j - B[i] >= 0 && dp[pre][j - B[i]] != -1e9) dp[now][j] = max(dp[now][j], dp[pre][j - B[i]] + min(n, B[i])); } } for(int j = sum; j < N * N; j++) if(dp[m & 1][j] >= n * k) return !printf("%d\n", j - sum); printf("Impossible\n"); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 1024 KB | Output is correct |
2 | Correct | 5 ms | 1024 KB | Output is correct |
3 | Correct | 5 ms | 1024 KB | Output is correct |
4 | Correct | 5 ms | 1024 KB | Output is correct |
5 | Correct | 5 ms | 1024 KB | Output is correct |
6 | Correct | 5 ms | 384 KB | Output is correct |
7 | Correct | 5 ms | 384 KB | Output is correct |
8 | Correct | 5 ms | 1024 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 1024 KB | Output is correct |
2 | Correct | 5 ms | 1024 KB | Output is correct |
3 | Correct | 5 ms | 1024 KB | Output is correct |
4 | Correct | 5 ms | 1024 KB | Output is correct |
5 | Correct | 5 ms | 1024 KB | Output is correct |
6 | Correct | 5 ms | 384 KB | Output is correct |
7 | Correct | 5 ms | 384 KB | Output is correct |
8 | Correct | 5 ms | 1024 KB | Output is correct |
9 | Correct | 7 ms | 1024 KB | Output is correct |
10 | Correct | 7 ms | 1024 KB | Output is correct |
11 | Correct | 7 ms | 1024 KB | Output is correct |
12 | Correct | 7 ms | 1024 KB | Output is correct |
13 | Correct | 7 ms | 1024 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 38 ms | 1024 KB | Output is correct |
2 | Correct | 35 ms | 1024 KB | Output is correct |
3 | Correct | 44 ms | 1024 KB | Output is correct |
4 | Correct | 46 ms | 1024 KB | Output is correct |
5 | Correct | 46 ms | 1024 KB | Output is correct |
6 | Correct | 33 ms | 896 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 9 ms | 1024 KB | Output is correct |
2 | Correct | 10 ms | 1024 KB | Output is correct |
3 | Correct | 9 ms | 1024 KB | Output is correct |
4 | Correct | 11 ms | 1024 KB | Output is correct |
5 | Correct | 4 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 5 ms | 1024 KB | Output is correct |
2 | Correct | 5 ms | 1024 KB | Output is correct |
3 | Correct | 5 ms | 1024 KB | Output is correct |
4 | Correct | 5 ms | 1024 KB | Output is correct |
5 | Correct | 5 ms | 1024 KB | Output is correct |
6 | Correct | 5 ms | 384 KB | Output is correct |
7 | Correct | 5 ms | 384 KB | Output is correct |
8 | Correct | 5 ms | 1024 KB | Output is correct |
9 | Correct | 7 ms | 1024 KB | Output is correct |
10 | Correct | 7 ms | 1024 KB | Output is correct |
11 | Correct | 7 ms | 1024 KB | Output is correct |
12 | Correct | 7 ms | 1024 KB | Output is correct |
13 | Correct | 7 ms | 1024 KB | Output is correct |
14 | Correct | 38 ms | 1024 KB | Output is correct |
15 | Correct | 35 ms | 1024 KB | Output is correct |
16 | Correct | 44 ms | 1024 KB | Output is correct |
17 | Correct | 46 ms | 1024 KB | Output is correct |
18 | Correct | 46 ms | 1024 KB | Output is correct |
19 | Correct | 33 ms | 896 KB | Output is correct |
20 | Correct | 9 ms | 1024 KB | Output is correct |
21 | Correct | 10 ms | 1024 KB | Output is correct |
22 | Correct | 9 ms | 1024 KB | Output is correct |
23 | Correct | 11 ms | 1024 KB | Output is correct |
24 | Correct | 4 ms | 384 KB | Output is correct |
25 | Correct | 31 ms | 1024 KB | Output is correct |
26 | Correct | 37 ms | 1072 KB | Output is correct |
27 | Correct | 26 ms | 1024 KB | Output is correct |
28 | Correct | 37 ms | 1024 KB | Output is correct |
29 | Correct | 40 ms | 1024 KB | Output is correct |
30 | Correct | 46 ms | 1024 KB | Output is correct |