# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
745846 |
2023-05-21T08:44:35 Z |
vjudge1 |
Kitchen (BOI19_kitchen) |
C++17 |
|
456 ms |
22948 KB |
#include <iostream>
#include <vector>
using namespace std;
int const MAX_N = 300;
int const MAX_M = 15;
int const MAX_WORK = MAX_N * (MAX_M + 1);
bool dp[MAX_WORK + 1][MAX_WORK + 1];
int main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int n, m, k;
cin >> n >> m >> k;
vector<int> a(n);
int total_work = 0;
for (int& x : a) {
cin >> x;
total_work += x;
if (x < k) {
cout << "Impossible\n";
return 0;
}
}
int const difference_work = n * k;
if (total_work > MAX_WORK || difference_work > MAX_WORK) {
cout << "Impossible\n";
return 0;
}
vector<int> b(m);
for (int& x : b)
cin >> x;
dp[0][0] = true;
for (int const& chef : b) {
int const delta_d = min(chef, n);
int const delta_t = chef;
for (int d = MAX_WORK; d >= delta_d; d--) {
for (int t = MAX_WORK; t >= delta_t; t--) {
dp[d][t] |= dp[d - delta_d][t - delta_t];
// if (dp[d][t]) {
// cout << "dp[" << d << "][" << t << "] possible!\n";
// }
}
}
}
for (int t = total_work; t <= MAX_WORK; t++) {
for (int d = difference_work; d <= MAX_WORK; d++) {
if (dp[d][t]) {
cout << t - total_work << "\n";
return 0;
}
}
}
cout << "Impossible\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
32 ms |
22740 KB |
Output is correct |
2 |
Correct |
35 ms |
22844 KB |
Output is correct |
3 |
Correct |
39 ms |
22828 KB |
Output is correct |
4 |
Correct |
42 ms |
22672 KB |
Output is correct |
5 |
Correct |
34 ms |
21592 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
171 ms |
22816 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
32 ms |
22740 KB |
Output is correct |
2 |
Correct |
35 ms |
22844 KB |
Output is correct |
3 |
Correct |
39 ms |
22828 KB |
Output is correct |
4 |
Correct |
42 ms |
22672 KB |
Output is correct |
5 |
Correct |
34 ms |
21592 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
171 ms |
22816 KB |
Output is correct |
9 |
Correct |
171 ms |
22820 KB |
Output is correct |
10 |
Correct |
167 ms |
22832 KB |
Output is correct |
11 |
Correct |
310 ms |
22788 KB |
Output is correct |
12 |
Correct |
167 ms |
22832 KB |
Output is correct |
13 |
Correct |
162 ms |
21708 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
449 ms |
22852 KB |
Output is correct |
2 |
Correct |
456 ms |
22948 KB |
Output is correct |
3 |
Correct |
442 ms |
22856 KB |
Output is correct |
4 |
Correct |
431 ms |
22860 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
32 ms |
22740 KB |
Output is correct |
2 |
Correct |
35 ms |
22844 KB |
Output is correct |
3 |
Correct |
39 ms |
22828 KB |
Output is correct |
4 |
Correct |
42 ms |
22672 KB |
Output is correct |
5 |
Correct |
34 ms |
21592 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
0 ms |
212 KB |
Output is correct |
8 |
Correct |
171 ms |
22816 KB |
Output is correct |
9 |
Correct |
171 ms |
22820 KB |
Output is correct |
10 |
Correct |
167 ms |
22832 KB |
Output is correct |
11 |
Correct |
310 ms |
22788 KB |
Output is correct |
12 |
Correct |
167 ms |
22832 KB |
Output is correct |
13 |
Correct |
162 ms |
21708 KB |
Output is correct |
14 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
15 |
Halted |
0 ms |
0 KB |
- |