# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
746272 |
2023-05-22T06:33:44 Z |
Szil |
Kitchen (BOI19_kitchen) |
C++14 |
|
25 ms |
716 KB |
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
const int MAXN = 301;
int a[MAXN], b[MAXN], dp[MAXN*MAXN];
int main() {
ios_base::sync_with_stdio(0); cin.tie(0);
int n, m, k, need = 0; cin >> n >> m >> k;
for (int i = 1; i <= n; i++) {
cin >> a[i];
need += a[i];
if (a[i] < k) {
cout << "Impossible\n";
return 0;
}
}
for (int i = 1; i <= m; i++) cin >> b[i];
fill(dp, dp+MAXN*MAXN, -1);
dp[0] = 0;
for (int i = 1; i <= m; i++) {
for (int s = MAXN*MAXN-1; s >= b[i]; s--) {
if (dp[s-b[i]] != -1)
dp[s] = max(dp[s], dp[s-b[i]] + min(n, b[i]));
}
}
for (int i = need; i < MAXN*MAXN; i++) {
if (dp[i] >= n*k) {
cout << i-need << "\n";
return 0;
}
}
cout << "Impossible\n";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
596 KB |
Output is correct |
2 |
Correct |
1 ms |
588 KB |
Output is correct |
3 |
Correct |
1 ms |
596 KB |
Output is correct |
4 |
Correct |
1 ms |
580 KB |
Output is correct |
5 |
Correct |
1 ms |
596 KB |
Output is correct |
6 |
Correct |
0 ms |
324 KB |
Output is correct |
7 |
Correct |
1 ms |
340 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 |
588 KB |
Output is correct |
3 |
Correct |
1 ms |
596 KB |
Output is correct |
4 |
Correct |
1 ms |
580 KB |
Output is correct |
5 |
Correct |
1 ms |
596 KB |
Output is correct |
6 |
Correct |
0 ms |
324 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
596 KB |
Output is correct |
9 |
Correct |
2 ms |
596 KB |
Output is correct |
10 |
Correct |
2 ms |
596 KB |
Output is correct |
11 |
Correct |
2 ms |
596 KB |
Output is correct |
12 |
Correct |
2 ms |
596 KB |
Output is correct |
13 |
Correct |
1 ms |
596 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
18 ms |
684 KB |
Output is correct |
2 |
Correct |
16 ms |
596 KB |
Output is correct |
3 |
Correct |
21 ms |
596 KB |
Output is correct |
4 |
Correct |
23 ms |
676 KB |
Output is correct |
5 |
Correct |
21 ms |
596 KB |
Output is correct |
6 |
Correct |
15 ms |
596 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
584 KB |
Output is correct |
2 |
Correct |
3 ms |
596 KB |
Output is correct |
3 |
Correct |
4 ms |
580 KB |
Output is correct |
4 |
Correct |
3 ms |
596 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
596 KB |
Output is correct |
2 |
Correct |
1 ms |
588 KB |
Output is correct |
3 |
Correct |
1 ms |
596 KB |
Output is correct |
4 |
Correct |
1 ms |
580 KB |
Output is correct |
5 |
Correct |
1 ms |
596 KB |
Output is correct |
6 |
Correct |
0 ms |
324 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
596 KB |
Output is correct |
9 |
Correct |
2 ms |
596 KB |
Output is correct |
10 |
Correct |
2 ms |
596 KB |
Output is correct |
11 |
Correct |
2 ms |
596 KB |
Output is correct |
12 |
Correct |
2 ms |
596 KB |
Output is correct |
13 |
Correct |
1 ms |
596 KB |
Output is correct |
14 |
Correct |
18 ms |
684 KB |
Output is correct |
15 |
Correct |
16 ms |
596 KB |
Output is correct |
16 |
Correct |
21 ms |
596 KB |
Output is correct |
17 |
Correct |
23 ms |
676 KB |
Output is correct |
18 |
Correct |
21 ms |
596 KB |
Output is correct |
19 |
Correct |
15 ms |
596 KB |
Output is correct |
20 |
Correct |
3 ms |
584 KB |
Output is correct |
21 |
Correct |
3 ms |
596 KB |
Output is correct |
22 |
Correct |
4 ms |
580 KB |
Output is correct |
23 |
Correct |
3 ms |
596 KB |
Output is correct |
24 |
Correct |
1 ms |
332 KB |
Output is correct |
25 |
Correct |
16 ms |
680 KB |
Output is correct |
26 |
Correct |
19 ms |
596 KB |
Output is correct |
27 |
Correct |
13 ms |
676 KB |
Output is correct |
28 |
Correct |
18 ms |
596 KB |
Output is correct |
29 |
Correct |
18 ms |
680 KB |
Output is correct |
30 |
Correct |
25 ms |
716 KB |
Output is correct |