# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
160603 | 2019-10-28T17:25:03 Z | luciocf | Kitchen (BOI19_kitchen) | C++14 | 43 ms | 760 KB |
#include <bits/stdc++.h> using namespace std; const int maxn = 310; const int maxs = 9e4+10; const int inf = 1e9+10; int n, m, k, tot; int a[maxn], b[maxn]; int dp[maxs]; int main(void) { scanf("%d %d %d", &n, &m, &k); for (int i = 1; i <= n; i++) { scanf("%d", &a[i]); tot += a[i]; } for (int i = 1; i <= m; i++) scanf("%d", &b[i]); for (int i = 1; i <= n; i++) { if (a[i] < k) { printf("Impossible\n"); return 0; } } for (int i = 1; i < maxs; i++) dp[i] = -inf; for (int i = 1; i <= m; i++) for (int j = maxs-1; j >= b[i]; j--) dp[j] = max(dp[j], dp[j-b[i]]+min(b[i], n)); int ans = -1; for (int i = tot; i < maxs; i++) { if (dp[i] >= n*k) { ans = i; break; } } if (ans == -1) printf("Impossible\n"); else printf("%d\n", ans-tot); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 632 KB | Output is correct |
2 | Correct | 2 ms | 632 KB | Output is correct |
3 | Correct | 3 ms | 632 KB | Output is correct |
4 | Correct | 3 ms | 632 KB | Output is correct |
5 | Correct | 3 ms | 632 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
8 | Correct | 3 ms | 632 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 632 KB | Output is correct |
2 | Correct | 2 ms | 632 KB | Output is correct |
3 | Correct | 3 ms | 632 KB | Output is correct |
4 | Correct | 3 ms | 632 KB | Output is correct |
5 | Correct | 3 ms | 632 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
8 | Correct | 3 ms | 632 KB | Output is correct |
9 | Correct | 3 ms | 636 KB | Output is correct |
10 | Correct | 4 ms | 632 KB | Output is correct |
11 | Correct | 4 ms | 632 KB | Output is correct |
12 | Correct | 12 ms | 632 KB | Output is correct |
13 | Correct | 4 ms | 632 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 25 ms | 632 KB | Output is correct |
2 | Correct | 22 ms | 608 KB | Output is correct |
3 | Correct | 29 ms | 632 KB | Output is correct |
4 | Correct | 28 ms | 732 KB | Output is correct |
5 | Correct | 28 ms | 632 KB | Output is correct |
6 | Correct | 20 ms | 744 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 632 KB | Output is correct |
2 | Correct | 4 ms | 632 KB | Output is correct |
3 | Correct | 6 ms | 632 KB | Output is correct |
4 | Correct | 6 ms | 632 KB | Output is correct |
5 | Correct | 2 ms | 252 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 632 KB | Output is correct |
2 | Correct | 2 ms | 632 KB | Output is correct |
3 | Correct | 3 ms | 632 KB | Output is correct |
4 | Correct | 3 ms | 632 KB | Output is correct |
5 | Correct | 3 ms | 632 KB | Output is correct |
6 | Correct | 2 ms | 376 KB | Output is correct |
7 | Correct | 2 ms | 376 KB | Output is correct |
8 | Correct | 3 ms | 632 KB | Output is correct |
9 | Correct | 3 ms | 636 KB | Output is correct |
10 | Correct | 4 ms | 632 KB | Output is correct |
11 | Correct | 4 ms | 632 KB | Output is correct |
12 | Correct | 12 ms | 632 KB | Output is correct |
13 | Correct | 4 ms | 632 KB | Output is correct |
14 | Correct | 25 ms | 632 KB | Output is correct |
15 | Correct | 22 ms | 608 KB | Output is correct |
16 | Correct | 29 ms | 632 KB | Output is correct |
17 | Correct | 28 ms | 732 KB | Output is correct |
18 | Correct | 28 ms | 632 KB | Output is correct |
19 | Correct | 20 ms | 744 KB | Output is correct |
20 | Correct | 6 ms | 632 KB | Output is correct |
21 | Correct | 4 ms | 632 KB | Output is correct |
22 | Correct | 6 ms | 632 KB | Output is correct |
23 | Correct | 6 ms | 632 KB | Output is correct |
24 | Correct | 2 ms | 252 KB | Output is correct |
25 | Correct | 21 ms | 632 KB | Output is correct |
26 | Correct | 23 ms | 632 KB | Output is correct |
27 | Correct | 16 ms | 632 KB | Output is correct |
28 | Correct | 43 ms | 632 KB | Output is correct |
29 | Correct | 20 ms | 760 KB | Output is correct |
30 | Correct | 29 ms | 636 KB | Output is correct |