# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1099422 | 2024-10-11T09:38:48 Z | vjudge1 | Kitchen (BOI19_kitchen) | C++17 | 21 ms | 1884 KB |
#include <bits/stdc++.h> using namespace std; #define int long long #define fileio(name) if (fopen(name".inp", "r")) freopen(name".inp", "r", stdin), freopen(name".out", "w", stdout) const int maxn = 301, inf = 1e18; int n, m, k, a[maxn], b[maxn], f[2][maxn*maxn]; int32_t main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); fileio(""); // freopen("debug.txt", "w", stderr); cin >> n >> m >> k; for (int i = 1; i <= n; i++) { cin >> a[i]; if (a[i] < k) { cout << "Impossible"; return 0; } } for (int i = 1; i <= m; i++) { cin >> b[i]; } for (int i = 1; i <= 300*300; i++) { f[0][i] = -inf; } for (int i = 1; i <= m; i++) { for (int j = 0; j <= 300*300; j++) { f[i%2][j] = f[(i-1)%2][j]; if (j >= b[i]) { f[i%2][j] = max(f[i%2][j], f[(i-1)%2][j - b[i]] + min(n, b[i])); } } } int res = inf, sum = accumulate(a+1, a+1+n, 0LL); for (int i = sum; i <= 300*300; i++) { if (f[m%2][i] >= n*k) { res = i; break; } } if (res < inf) { cout << res - sum; } else { cout << "Impossible"; } return 0 ^ 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 1884 KB | Output is correct |
2 | Correct | 1 ms | 1716 KB | Output is correct |
3 | Correct | 1 ms | 1628 KB | Output is correct |
4 | Correct | 1 ms | 1884 KB | Output is correct |
5 | Correct | 1 ms | 1884 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 1 ms | 344 KB | Output is correct |
8 | Correct | 1 ms | 1884 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 1884 KB | Output is correct |
2 | Correct | 1 ms | 1716 KB | Output is correct |
3 | Correct | 1 ms | 1628 KB | Output is correct |
4 | Correct | 1 ms | 1884 KB | Output is correct |
5 | Correct | 1 ms | 1884 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 1 ms | 344 KB | Output is correct |
8 | Correct | 1 ms | 1884 KB | Output is correct |
9 | Correct | 2 ms | 1628 KB | Output is correct |
10 | Correct | 2 ms | 1884 KB | Output is correct |
11 | Correct | 2 ms | 1628 KB | Output is correct |
12 | Correct | 2 ms | 1628 KB | Output is correct |
13 | Correct | 2 ms | 1884 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 19 ms | 1884 KB | Output is correct |
2 | Correct | 16 ms | 1628 KB | Output is correct |
3 | Correct | 21 ms | 1884 KB | Output is correct |
4 | Correct | 21 ms | 1884 KB | Output is correct |
5 | Correct | 20 ms | 1624 KB | Output is correct |
6 | Correct | 15 ms | 1884 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 1628 KB | Output is correct |
2 | Correct | 4 ms | 1628 KB | Output is correct |
3 | Correct | 4 ms | 1884 KB | Output is correct |
4 | Correct | 4 ms | 1880 KB | Output is correct |
5 | Correct | 0 ms | 348 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 1884 KB | Output is correct |
2 | Correct | 1 ms | 1716 KB | Output is correct |
3 | Correct | 1 ms | 1628 KB | Output is correct |
4 | Correct | 1 ms | 1884 KB | Output is correct |
5 | Correct | 1 ms | 1884 KB | Output is correct |
6 | Correct | 0 ms | 348 KB | Output is correct |
7 | Correct | 1 ms | 344 KB | Output is correct |
8 | Correct | 1 ms | 1884 KB | Output is correct |
9 | Correct | 2 ms | 1628 KB | Output is correct |
10 | Correct | 2 ms | 1884 KB | Output is correct |
11 | Correct | 2 ms | 1628 KB | Output is correct |
12 | Correct | 2 ms | 1628 KB | Output is correct |
13 | Correct | 2 ms | 1884 KB | Output is correct |
14 | Correct | 19 ms | 1884 KB | Output is correct |
15 | Correct | 16 ms | 1628 KB | Output is correct |
16 | Correct | 21 ms | 1884 KB | Output is correct |
17 | Correct | 21 ms | 1884 KB | Output is correct |
18 | Correct | 20 ms | 1624 KB | Output is correct |
19 | Correct | 15 ms | 1884 KB | Output is correct |
20 | Correct | 4 ms | 1628 KB | Output is correct |
21 | Correct | 4 ms | 1628 KB | Output is correct |
22 | Correct | 4 ms | 1884 KB | Output is correct |
23 | Correct | 4 ms | 1880 KB | Output is correct |
24 | Correct | 0 ms | 348 KB | Output is correct |
25 | Correct | 15 ms | 1880 KB | Output is correct |
26 | Correct | 17 ms | 1876 KB | Output is correct |
27 | Correct | 12 ms | 1884 KB | Output is correct |
28 | Correct | 17 ms | 1880 KB | Output is correct |
29 | Correct | 18 ms | 1628 KB | Output is correct |
30 | Correct | 21 ms | 1884 KB | Output is correct |