# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
724029 | 2023-04-14T15:48:34 Z | lovrot | Kitchen (BOI19_kitchen) | C++17 | 12 ms | 804 KB |
#include <cstdio> #include <algorithm> using namespace std; const int N = 310; const int INF = 2e9; int n, m, k, A[N], B[N]; int dp[2][N * N]; int main() { for(int i = 0; i < N * N; i++) dp[0][i] = -INF; dp[0][0] = 0; scanf("%d%d%d", &n, &m, &k); int nim = INF, sum = 0; for(int i = 0; i < n; i++) { scanf("%d", A + i); nim = min(nim, A[i]); sum += A[i]; } for(int i = 0; i < m; i++) scanf("%d", B + i); if(nim < k) { printf("Impossible\n"); return 0; } bool f = 0; int _sum = 0; for(int i = 0; i < m; i++) { f ^= 1; _sum += B[i]; for(int j = 0; j <= _sum; j++) { dp[f][j] = dp[!f][j]; if(B[i] <= j) dp[f][j] = max(dp[f][j], dp[!f][j - B[i]] + min(n, B[i])); } } for(int i = sum; i < N * N; i++) if(dp[f][i] >= n * k) { printf("%d\n", i - sum); return 0; } printf("Impossible\n"); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 596 KB | Output is correct |
2 | Correct | 1 ms | 596 KB | Output is correct |
3 | Correct | 1 ms | 596 KB | Output is correct |
4 | Correct | 1 ms | 596 KB | Output is correct |
5 | Correct | 1 ms | 596 KB | Output is correct |
6 | Correct | 1 ms | 596 KB | Output is correct |
7 | Correct | 1 ms | 596 KB | Output is correct |
8 | Correct | 1 ms | 596 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 596 KB | Output is correct |
2 | Correct | 1 ms | 596 KB | Output is correct |
3 | Correct | 1 ms | 596 KB | Output is correct |
4 | Correct | 1 ms | 596 KB | Output is correct |
5 | Correct | 1 ms | 596 KB | Output is correct |
6 | Correct | 1 ms | 596 KB | Output is correct |
7 | Correct | 1 ms | 596 KB | Output is correct |
8 | Correct | 1 ms | 596 KB | Output is correct |
9 | Correct | 1 ms | 596 KB | Output is correct |
10 | Correct | 1 ms | 596 KB | Output is correct |
11 | Correct | 1 ms | 596 KB | Output is correct |
12 | Correct | 1 ms | 596 KB | Output is correct |
13 | Incorrect | 1 ms | 596 KB | Output isn't correct |
14 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 12 ms | 804 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 596 KB | Output is correct |
2 | Correct | 1 ms | 596 KB | Output is correct |
3 | Correct | 1 ms | 596 KB | Output is correct |
4 | Correct | 1 ms | 596 KB | Output is correct |
5 | Correct | 1 ms | 596 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 596 KB | Output is correct |
2 | Correct | 1 ms | 596 KB | Output is correct |
3 | Correct | 1 ms | 596 KB | Output is correct |
4 | Correct | 1 ms | 596 KB | Output is correct |
5 | Correct | 1 ms | 596 KB | Output is correct |
6 | Correct | 1 ms | 596 KB | Output is correct |
7 | Correct | 1 ms | 596 KB | Output is correct |
8 | Correct | 1 ms | 596 KB | Output is correct |
9 | Correct | 1 ms | 596 KB | Output is correct |
10 | Correct | 1 ms | 596 KB | Output is correct |
11 | Correct | 1 ms | 596 KB | Output is correct |
12 | Correct | 1 ms | 596 KB | Output is correct |
13 | Incorrect | 1 ms | 596 KB | Output isn't correct |
14 | Halted | 0 ms | 0 KB | - |