# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
651934 |
2022-10-20T14:52:22 Z |
ymm |
Kitchen (BOI19_kitchen) |
C++17 |
|
238 ms |
4812 KB |
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx")
#include <bits/stdc++.h>
#define Loop(x,l,r) for (ll x = (l); x < (ll)(r); ++x)
#define LoopR(x,l,r) for (ll x = (r)-1; x >= (ll)(l); --x)
typedef long long ll;
typedef std::pair<int, int> pii;
typedef std::pair<ll , ll > pll;
using namespace std;
const int N = 320;
int meal_cnt, chef_cnt, k;
int chef_time[N], meal_sum_time;
bitset<N*N> less_bs;
int nxt_less[N*N];
bitset<N*N> more_bs[N];
vector<int> less_chef;
vector<int> more_chef;
int main()
{
cin.tie(0) -> sync_with_stdio(false);
cin >> meal_cnt >> chef_cnt >> k;
Loop (i,0,meal_cnt) {
int x;
cin >> x;
if (x < k) {
cout << "Impossible\n";
return 0;
}
meal_sum_time += x;
}
Loop (i,0,chef_cnt) {
int x;
cin >> x;
(x <= meal_cnt? less_chef: more_chef).push_back(x);
}
less_bs[0] = 1;
for (int x : less_chef)
less_bs |= less_bs << x;
nxt_less[N*N-1] = N*N;
LoopR (i,0,N*N-1)
nxt_less[i] = less_bs[i]? i: nxt_less[i+1];
more_bs[0][0] = 1;
for (int x : more_chef) {
LoopR (i,1,N)
more_bs[i] |= more_bs[i-1] << x;
}
int ans = N*N;
Loop (cnt_more,0,N) Loop (time_more,0,N*N) {
if (!more_bs[cnt_more][time_more])
continue;
int req = 0;
req = max(req, meal_sum_time - (int)time_more);
req = max(req, (int)(k-cnt_more)*meal_cnt);
if (req >= N*N || nxt_less[req] == N*N)
continue;
ans = min(ans, nxt_less[req] + (int)time_more - meal_sum_time);
}
if (ans == N*N)
cout << "Impossible\n";
else
cout << ans << '\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
30 ms |
4692 KB |
Output is correct |
2 |
Correct |
30 ms |
4692 KB |
Output is correct |
3 |
Correct |
31 ms |
4692 KB |
Output is correct |
4 |
Correct |
30 ms |
4692 KB |
Output is correct |
5 |
Correct |
28 ms |
768 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
32 ms |
4692 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
30 ms |
4692 KB |
Output is correct |
2 |
Correct |
30 ms |
4692 KB |
Output is correct |
3 |
Correct |
31 ms |
4692 KB |
Output is correct |
4 |
Correct |
30 ms |
4692 KB |
Output is correct |
5 |
Correct |
28 ms |
768 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
32 ms |
4692 KB |
Output is correct |
9 |
Correct |
39 ms |
4692 KB |
Output is correct |
10 |
Correct |
38 ms |
4692 KB |
Output is correct |
11 |
Correct |
34 ms |
4812 KB |
Output is correct |
12 |
Correct |
26 ms |
724 KB |
Output is correct |
13 |
Correct |
26 ms |
724 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
31 ms |
724 KB |
Output is correct |
2 |
Correct |
28 ms |
724 KB |
Output is correct |
3 |
Correct |
43 ms |
4748 KB |
Output is correct |
4 |
Correct |
103 ms |
4748 KB |
Output is correct |
5 |
Correct |
38 ms |
776 KB |
Output is correct |
6 |
Correct |
28 ms |
772 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
54 ms |
4692 KB |
Output is correct |
2 |
Correct |
42 ms |
4744 KB |
Output is correct |
3 |
Correct |
27 ms |
724 KB |
Output is correct |
4 |
Correct |
33 ms |
724 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
30 ms |
4692 KB |
Output is correct |
2 |
Correct |
30 ms |
4692 KB |
Output is correct |
3 |
Correct |
31 ms |
4692 KB |
Output is correct |
4 |
Correct |
30 ms |
4692 KB |
Output is correct |
5 |
Correct |
28 ms |
768 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
32 ms |
4692 KB |
Output is correct |
9 |
Correct |
39 ms |
4692 KB |
Output is correct |
10 |
Correct |
38 ms |
4692 KB |
Output is correct |
11 |
Correct |
34 ms |
4812 KB |
Output is correct |
12 |
Correct |
26 ms |
724 KB |
Output is correct |
13 |
Correct |
26 ms |
724 KB |
Output is correct |
14 |
Correct |
31 ms |
724 KB |
Output is correct |
15 |
Correct |
28 ms |
724 KB |
Output is correct |
16 |
Correct |
43 ms |
4748 KB |
Output is correct |
17 |
Correct |
103 ms |
4748 KB |
Output is correct |
18 |
Correct |
38 ms |
776 KB |
Output is correct |
19 |
Correct |
28 ms |
772 KB |
Output is correct |
20 |
Correct |
54 ms |
4692 KB |
Output is correct |
21 |
Correct |
42 ms |
4744 KB |
Output is correct |
22 |
Correct |
27 ms |
724 KB |
Output is correct |
23 |
Correct |
33 ms |
724 KB |
Output is correct |
24 |
Correct |
1 ms |
340 KB |
Output is correct |
25 |
Correct |
161 ms |
4692 KB |
Output is correct |
26 |
Correct |
158 ms |
4744 KB |
Output is correct |
27 |
Correct |
97 ms |
4744 KB |
Output is correct |
28 |
Correct |
123 ms |
4748 KB |
Output is correct |
29 |
Correct |
238 ms |
4732 KB |
Output is correct |
30 |
Correct |
129 ms |
4744 KB |
Output is correct |