# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
133036 |
2019-07-20T05:38:59 Z |
E869120 |
Kitchen (BOI19_kitchen) |
C++14 |
|
161 ms |
106488 KB |
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int N, M, K, S, A[1 << 18], B[1 << 18];
int dp[309][90009];
int solve_subtask5() {
for (int i = 0; i <= M; i++) {
for (int j = 0; j <= 90000; j++) dp[i][j] = -(1 << 30);
}
dp[0][0] = 0;
for (int i = 0; i < M; i++) {
for (int j = 0; j <= 90000; j++) {
if (dp[i][j] == -(1 << 30)) continue;
dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
dp[i + 1][j + B[i]] = max(dp[i + 1][j + B[i]], dp[i][j] + min(B[i], N));
}
}
for (int i = S; i <= 90000; i++) {
if (dp[M][i] >= N * K) return i - S;
}
return (1 << 30);
}
int main() {
cin >> N >> M >> K;
for (int i = 0; i < N; i++) {
cin >> A[i]; S += A[i];
if (A[i] < K) {
cout << "Impossible" << endl;
return 0;
}
}
for (int i = 0; i < M; i++) cin >> B[i];
int ans = solve_subtask5();
if (ans == (1 << 30)) cout << "Impossible" << endl;
else cout << ans << endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
1400 KB |
Output is correct |
2 |
Correct |
3 ms |
1388 KB |
Output is correct |
3 |
Correct |
3 ms |
1400 KB |
Output is correct |
4 |
Correct |
3 ms |
1400 KB |
Output is correct |
5 |
Correct |
3 ms |
1400 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
256 KB |
Output is correct |
8 |
Correct |
3 ms |
1400 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
1400 KB |
Output is correct |
2 |
Correct |
3 ms |
1388 KB |
Output is correct |
3 |
Correct |
3 ms |
1400 KB |
Output is correct |
4 |
Correct |
3 ms |
1400 KB |
Output is correct |
5 |
Correct |
3 ms |
1400 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
256 KB |
Output is correct |
8 |
Correct |
3 ms |
1400 KB |
Output is correct |
9 |
Correct |
8 ms |
6008 KB |
Output is correct |
10 |
Correct |
8 ms |
6008 KB |
Output is correct |
11 |
Correct |
8 ms |
6008 KB |
Output is correct |
12 |
Correct |
8 ms |
6008 KB |
Output is correct |
13 |
Correct |
8 ms |
6008 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
114 ms |
92680 KB |
Output is correct |
2 |
Correct |
96 ms |
80436 KB |
Output is correct |
3 |
Correct |
143 ms |
106488 KB |
Output is correct |
4 |
Correct |
161 ms |
106488 KB |
Output is correct |
5 |
Correct |
149 ms |
102904 KB |
Output is correct |
6 |
Correct |
89 ms |
73976 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
18 ms |
14712 KB |
Output is correct |
2 |
Correct |
18 ms |
14840 KB |
Output is correct |
3 |
Correct |
17 ms |
14712 KB |
Output is correct |
4 |
Correct |
18 ms |
14812 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
1400 KB |
Output is correct |
2 |
Correct |
3 ms |
1388 KB |
Output is correct |
3 |
Correct |
3 ms |
1400 KB |
Output is correct |
4 |
Correct |
3 ms |
1400 KB |
Output is correct |
5 |
Correct |
3 ms |
1400 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
256 KB |
Output is correct |
8 |
Correct |
3 ms |
1400 KB |
Output is correct |
9 |
Correct |
8 ms |
6008 KB |
Output is correct |
10 |
Correct |
8 ms |
6008 KB |
Output is correct |
11 |
Correct |
8 ms |
6008 KB |
Output is correct |
12 |
Correct |
8 ms |
6008 KB |
Output is correct |
13 |
Correct |
8 ms |
6008 KB |
Output is correct |
14 |
Correct |
114 ms |
92680 KB |
Output is correct |
15 |
Correct |
96 ms |
80436 KB |
Output is correct |
16 |
Correct |
143 ms |
106488 KB |
Output is correct |
17 |
Correct |
161 ms |
106488 KB |
Output is correct |
18 |
Correct |
149 ms |
102904 KB |
Output is correct |
19 |
Correct |
89 ms |
73976 KB |
Output is correct |
20 |
Correct |
18 ms |
14712 KB |
Output is correct |
21 |
Correct |
18 ms |
14840 KB |
Output is correct |
22 |
Correct |
17 ms |
14712 KB |
Output is correct |
23 |
Correct |
18 ms |
14812 KB |
Output is correct |
24 |
Correct |
2 ms |
376 KB |
Output is correct |
25 |
Correct |
87 ms |
74768 KB |
Output is correct |
26 |
Correct |
103 ms |
86344 KB |
Output is correct |
27 |
Correct |
71 ms |
57100 KB |
Output is correct |
28 |
Correct |
118 ms |
86692 KB |
Output is correct |
29 |
Correct |
128 ms |
88696 KB |
Output is correct |
30 |
Correct |
161 ms |
106360 KB |
Output is correct |