# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
985272 |
2024-05-17T14:07:34 Z |
OAleksa |
Kitchen (BOI19_kitchen) |
C++14 |
|
40 ms |
1360 KB |
#include <bits/stdc++.h>
#define f first
#define s second
using namespace std;
const int N = 310;
int n, m, k, a[N], b[N];
int dp[N * N], ndp[N * N];
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int tt = 1;
//cin >> tt;
while (tt--) {
cin >> n >> m >> k;
for (int i = 1;i <= n;i++)
cin >> a[i];
sort(a + 1, a + n + 1);
for (int i = 1;i <= m;i++)
cin >> b[i];
sort(b + 1, b + m + 1);
if (m < k || a[1] < k)
cout << "Impossible";
else {
for (int i = 1;i < N * N;i++)
dp[i] = -1e9;
dp[0] = 0;
for (int i = 1;i <= m;i++) {
for (int j = 0;j < N * N;j++) {
if (j < b[i])
ndp[j] = dp[j];
else {
ndp[j] = max(dp[j], dp[j - b[i]] + min(n, b[i]));
}
}
for (int i = 0;i < N * N;i++)
dp[i] = ndp[i], ndp[i] = 0;
}
int s = 0, ans = 1e9;
for (int i = 1;i <= n;i++)
s += a[i];
for (int i = N * N - 1;i >= s;i--) {
if (dp[i] >= n * k) {
ans = i - s;
}
}
if (ans == 1e9)
cout << "Impossible\n";
else
cout << ans << '\n';
}
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1116 KB |
Output is correct |
2 |
Correct |
1 ms |
1116 KB |
Output is correct |
3 |
Correct |
1 ms |
1116 KB |
Output is correct |
4 |
Correct |
1 ms |
1116 KB |
Output is correct |
5 |
Correct |
1 ms |
1116 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
1116 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1116 KB |
Output is correct |
2 |
Correct |
1 ms |
1116 KB |
Output is correct |
3 |
Correct |
1 ms |
1116 KB |
Output is correct |
4 |
Correct |
1 ms |
1116 KB |
Output is correct |
5 |
Correct |
1 ms |
1116 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
1116 KB |
Output is correct |
9 |
Correct |
2 ms |
1116 KB |
Output is correct |
10 |
Correct |
2 ms |
1116 KB |
Output is correct |
11 |
Correct |
2 ms |
1116 KB |
Output is correct |
12 |
Correct |
2 ms |
976 KB |
Output is correct |
13 |
Correct |
3 ms |
1116 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
32 ms |
1116 KB |
Output is correct |
2 |
Correct |
25 ms |
1116 KB |
Output is correct |
3 |
Correct |
34 ms |
1116 KB |
Output is correct |
4 |
Correct |
40 ms |
1116 KB |
Output is correct |
5 |
Correct |
35 ms |
1360 KB |
Output is correct |
6 |
Correct |
26 ms |
1112 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
1116 KB |
Output is correct |
2 |
Correct |
5 ms |
1212 KB |
Output is correct |
3 |
Correct |
5 ms |
1112 KB |
Output is correct |
4 |
Correct |
5 ms |
1112 KB |
Output is correct |
5 |
Correct |
1 ms |
372 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
1116 KB |
Output is correct |
2 |
Correct |
1 ms |
1116 KB |
Output is correct |
3 |
Correct |
1 ms |
1116 KB |
Output is correct |
4 |
Correct |
1 ms |
1116 KB |
Output is correct |
5 |
Correct |
1 ms |
1116 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
1116 KB |
Output is correct |
9 |
Correct |
2 ms |
1116 KB |
Output is correct |
10 |
Correct |
2 ms |
1116 KB |
Output is correct |
11 |
Correct |
2 ms |
1116 KB |
Output is correct |
12 |
Correct |
2 ms |
976 KB |
Output is correct |
13 |
Correct |
3 ms |
1116 KB |
Output is correct |
14 |
Correct |
32 ms |
1116 KB |
Output is correct |
15 |
Correct |
25 ms |
1116 KB |
Output is correct |
16 |
Correct |
34 ms |
1116 KB |
Output is correct |
17 |
Correct |
40 ms |
1116 KB |
Output is correct |
18 |
Correct |
35 ms |
1360 KB |
Output is correct |
19 |
Correct |
26 ms |
1112 KB |
Output is correct |
20 |
Correct |
5 ms |
1116 KB |
Output is correct |
21 |
Correct |
5 ms |
1212 KB |
Output is correct |
22 |
Correct |
5 ms |
1112 KB |
Output is correct |
23 |
Correct |
5 ms |
1112 KB |
Output is correct |
24 |
Correct |
1 ms |
372 KB |
Output is correct |
25 |
Correct |
23 ms |
1112 KB |
Output is correct |
26 |
Correct |
30 ms |
1212 KB |
Output is correct |
27 |
Correct |
19 ms |
1116 KB |
Output is correct |
28 |
Correct |
26 ms |
1116 KB |
Output is correct |
29 |
Correct |
27 ms |
1112 KB |
Output is correct |
30 |
Correct |
40 ms |
1112 KB |
Output is correct |