# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
764661 |
2023-06-23T18:48:13 Z |
Meloric |
Kitchen (BOI19_kitchen) |
C++17 |
|
30 ms |
980 KB |
#include <bits/stdc++.h>
#define pb push_back
#define int int64_t
#define pii pair<int, int>
#define X first
#define Y second
#define all(x) (x).begin(),(x).end()
#define lb lower_bound
#define ub upper_bound
using namespace std;
const int inf = 1e9;
void p(auto A){
for(auto e : A)cout << e << ' ';
cout << '\n';
}
void solve(){
int n, m, k; cin >> n >> m >> k;
vector<int>A(n), B(m);
for(int i = 0; i< n; i++)cin >> A[i];
for(int i = 0; i< m; i++)cin >> B[i];
for(auto e : A)if(e < k){
cout << "Impossible";
return;
}
int tot = accumulate(all(B), 0);
vector<int> dp(tot+5, -inf);
dp[0] = 0;
auto xmax = [](int& a, int b){a=max(a, b);};
for(int i = 0; i< m; i++){
for(int j = tot-B[i]; j >= 0; j--){
xmax(dp[j+B[i]], dp[j]+min(n, B[i]));
}
}
int sma = accumulate(all(A), 0);
for(int i = sma; i<= tot; i++){
if(dp[i] >= k*n){
cout << i-sma;
return;
}
}
cout << "Impossible";
}
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t = 1;
//cin >> t;
while(t--)solve();
}
Compilation message
kitchen.cpp:15:8: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
15 | void p(auto A){
| ^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
320 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
320 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
316 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
24 ms |
724 KB |
Output is correct |
2 |
Correct |
15 ms |
724 KB |
Output is correct |
3 |
Correct |
17 ms |
700 KB |
Output is correct |
4 |
Correct |
29 ms |
980 KB |
Output is correct |
5 |
Correct |
29 ms |
980 KB |
Output is correct |
6 |
Correct |
12 ms |
724 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
316 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
320 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
316 KB |
Output is correct |
14 |
Correct |
24 ms |
724 KB |
Output is correct |
15 |
Correct |
15 ms |
724 KB |
Output is correct |
16 |
Correct |
17 ms |
700 KB |
Output is correct |
17 |
Correct |
29 ms |
980 KB |
Output is correct |
18 |
Correct |
29 ms |
980 KB |
Output is correct |
19 |
Correct |
12 ms |
724 KB |
Output is correct |
20 |
Correct |
1 ms |
316 KB |
Output is correct |
21 |
Correct |
1 ms |
212 KB |
Output is correct |
22 |
Correct |
1 ms |
212 KB |
Output is correct |
23 |
Correct |
1 ms |
212 KB |
Output is correct |
24 |
Correct |
1 ms |
212 KB |
Output is correct |
25 |
Correct |
15 ms |
724 KB |
Output is correct |
26 |
Correct |
18 ms |
724 KB |
Output is correct |
27 |
Correct |
6 ms |
468 KB |
Output is correct |
28 |
Correct |
15 ms |
704 KB |
Output is correct |
29 |
Correct |
21 ms |
852 KB |
Output is correct |
30 |
Correct |
30 ms |
980 KB |
Output is correct |