# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
509574 |
2022-01-14T07:00:26 Z |
kianaRZV |
Kitchen (BOI19_kitchen) |
C++14 |
|
101 ms |
119736 KB |
#include <bits/stdc++.h>
using namespace std;
const int maxn = 305, inf = 1e9 + 9;
int n, m, k, ans = inf, sum;
int a[maxn], b[maxn], dp[maxn][100005];
bool check = false;
void read_input() {
cin >> n >> m >> k;
for (int i = 1; i <= n; i++) {
cin >> a[i];
sum += a[i];
check |= (a[i] < k);
}
for (int i = 1; i <= m; i++)
cin >> b[i];
}
void solve() {
memset(dp, -0x3f, sizeof(dp));
dp[0][0] = 0;
for (int i = 1; i <= m; i++)
for (int j = 0; j < 100005; j++) {
dp[i][j] = dp[i - 1][j];
if (j - b[i] >= 0)
dp[i][j] = max(dp[i][j], dp[i - 1][j - b[i]] + min(n, b[i]));
if (j >= sum && dp[i][j] >= n * k)
ans = min(ans, j - sum);
}
if (check || ans >= inf)
cout << "Impossible";
else
cout << ans;
}
int32_t main() {
ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
read_input(), solve();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
54 ms |
119572 KB |
Output is correct |
2 |
Correct |
44 ms |
119600 KB |
Output is correct |
3 |
Correct |
44 ms |
119592 KB |
Output is correct |
4 |
Correct |
43 ms |
119640 KB |
Output is correct |
5 |
Correct |
44 ms |
119604 KB |
Output is correct |
6 |
Correct |
45 ms |
119608 KB |
Output is correct |
7 |
Correct |
41 ms |
119608 KB |
Output is correct |
8 |
Correct |
48 ms |
119592 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
54 ms |
119572 KB |
Output is correct |
2 |
Correct |
44 ms |
119600 KB |
Output is correct |
3 |
Correct |
44 ms |
119592 KB |
Output is correct |
4 |
Correct |
43 ms |
119640 KB |
Output is correct |
5 |
Correct |
44 ms |
119604 KB |
Output is correct |
6 |
Correct |
45 ms |
119608 KB |
Output is correct |
7 |
Correct |
41 ms |
119608 KB |
Output is correct |
8 |
Correct |
48 ms |
119592 KB |
Output is correct |
9 |
Correct |
47 ms |
119624 KB |
Output is correct |
10 |
Correct |
55 ms |
119620 KB |
Output is correct |
11 |
Correct |
49 ms |
119612 KB |
Output is correct |
12 |
Correct |
48 ms |
119620 KB |
Output is correct |
13 |
Correct |
48 ms |
119608 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
101 ms |
119708 KB |
Output is correct |
2 |
Correct |
99 ms |
119680 KB |
Output is correct |
3 |
Correct |
99 ms |
119680 KB |
Output is correct |
4 |
Correct |
95 ms |
119676 KB |
Output is correct |
5 |
Correct |
89 ms |
119644 KB |
Output is correct |
6 |
Correct |
81 ms |
119672 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
60 ms |
119632 KB |
Output is correct |
2 |
Correct |
52 ms |
119620 KB |
Output is correct |
3 |
Correct |
53 ms |
119592 KB |
Output is correct |
4 |
Correct |
52 ms |
119564 KB |
Output is correct |
5 |
Correct |
52 ms |
119620 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
54 ms |
119572 KB |
Output is correct |
2 |
Correct |
44 ms |
119600 KB |
Output is correct |
3 |
Correct |
44 ms |
119592 KB |
Output is correct |
4 |
Correct |
43 ms |
119640 KB |
Output is correct |
5 |
Correct |
44 ms |
119604 KB |
Output is correct |
6 |
Correct |
45 ms |
119608 KB |
Output is correct |
7 |
Correct |
41 ms |
119608 KB |
Output is correct |
8 |
Correct |
48 ms |
119592 KB |
Output is correct |
9 |
Correct |
47 ms |
119624 KB |
Output is correct |
10 |
Correct |
55 ms |
119620 KB |
Output is correct |
11 |
Correct |
49 ms |
119612 KB |
Output is correct |
12 |
Correct |
48 ms |
119620 KB |
Output is correct |
13 |
Correct |
48 ms |
119608 KB |
Output is correct |
14 |
Correct |
101 ms |
119708 KB |
Output is correct |
15 |
Correct |
99 ms |
119680 KB |
Output is correct |
16 |
Correct |
99 ms |
119680 KB |
Output is correct |
17 |
Correct |
95 ms |
119676 KB |
Output is correct |
18 |
Correct |
89 ms |
119644 KB |
Output is correct |
19 |
Correct |
81 ms |
119672 KB |
Output is correct |
20 |
Correct |
60 ms |
119632 KB |
Output is correct |
21 |
Correct |
52 ms |
119620 KB |
Output is correct |
22 |
Correct |
53 ms |
119592 KB |
Output is correct |
23 |
Correct |
52 ms |
119564 KB |
Output is correct |
24 |
Correct |
52 ms |
119620 KB |
Output is correct |
25 |
Correct |
77 ms |
119696 KB |
Output is correct |
26 |
Correct |
85 ms |
119676 KB |
Output is correct |
27 |
Correct |
76 ms |
119736 KB |
Output is correct |
28 |
Correct |
90 ms |
119600 KB |
Output is correct |
29 |
Correct |
85 ms |
119600 KB |
Output is correct |
30 |
Correct |
97 ms |
119676 KB |
Output is correct |