# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
762184 | 2023-06-21T03:39:35 Z | anha3k25cvp | Kitchen (BOI19_kitchen) | C++14 | 28 ms | 596 KB |
#include <bits/stdc++.h> #define ll long long #define ull unsigned long long #define dl double #define st first #define nd second #define II pair <int, int> using namespace std; const int N = 5 + 1e5; const int inf = 7 + 1e9; vector <int> a, f; int main() { #define TASKNAME "" ios_base :: sync_with_stdio (0); cin.tie (0); if ( fopen( TASKNAME".inp", "r" ) ) { freopen (TASKNAME".inp", "r", stdin); freopen (TASKNAME".out", "w", stdout); } int n, m, k; cin >> n >> m >> k; int val = 0; for (int i = 1; i <= n; i ++) { int x; cin >> x; if (x < k) { cout << "Impossible"; return 0; } val += x; } int ma = 0; a.assign(m + 1, 0); for (int i = 1; i <= m; i ++) { cin >> a[i]; ma += a[i]; } f.assign(ma + 1, -1); int ans = inf; f[0] = 0; for (int num = 0; num <= m; num ++) for (int sum = ma; sum >= 0; sum --) if (f[sum] >= 0) { if (num < m) f[sum + a[num + 1]] = max(f[sum + a[num + 1]], f[sum] + min(a[num + 1], n)); if (sum >= val && f[sum] >= n * k) ans = min(ans, sum); } if (ans < inf) cout << ans - val; else cout << "Impossible"; return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 320 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 320 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Correct | 1 ms | 212 KB | Output is correct |
10 | Correct | 1 ms | 340 KB | Output is correct |
11 | Correct | 1 ms | 212 KB | Output is correct |
12 | Correct | 1 ms | 212 KB | Output is correct |
13 | Correct | 1 ms | 212 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 15 ms | 468 KB | Output is correct |
2 | Correct | 13 ms | 468 KB | Output is correct |
3 | Correct | 17 ms | 448 KB | Output is correct |
4 | Correct | 28 ms | 596 KB | Output is correct |
5 | Correct | 26 ms | 596 KB | Output is correct |
6 | Correct | 10 ms | 468 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 0 ms | 212 KB | Output is correct |
4 | Correct | 0 ms | 256 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 1 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 212 KB | Output is correct |
4 | Correct | 1 ms | 320 KB | Output is correct |
5 | Correct | 1 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 1 ms | 212 KB | Output is correct |
8 | Correct | 1 ms | 212 KB | Output is correct |
9 | Correct | 1 ms | 212 KB | Output is correct |
10 | Correct | 1 ms | 340 KB | Output is correct |
11 | Correct | 1 ms | 212 KB | Output is correct |
12 | Correct | 1 ms | 212 KB | Output is correct |
13 | Correct | 1 ms | 212 KB | Output is correct |
14 | Correct | 15 ms | 468 KB | Output is correct |
15 | Correct | 13 ms | 468 KB | Output is correct |
16 | Correct | 17 ms | 448 KB | Output is correct |
17 | Correct | 28 ms | 596 KB | Output is correct |
18 | Correct | 26 ms | 596 KB | Output is correct |
19 | Correct | 10 ms | 468 KB | Output is correct |
20 | Correct | 0 ms | 212 KB | Output is correct |
21 | Correct | 0 ms | 212 KB | Output is correct |
22 | Correct | 0 ms | 212 KB | Output is correct |
23 | Correct | 0 ms | 256 KB | Output is correct |
24 | Correct | 0 ms | 212 KB | Output is correct |
25 | Correct | 9 ms | 468 KB | Output is correct |
26 | Correct | 13 ms | 468 KB | Output is correct |
27 | Correct | 5 ms | 432 KB | Output is correct |
28 | Correct | 15 ms | 468 KB | Output is correct |
29 | Correct | 21 ms | 596 KB | Output is correct |
30 | Correct | 28 ms | 580 KB | Output is correct |