# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
648720 |
2022-10-07T19:21:10 Z |
Lobo |
Kitchen (BOI19_kitchen) |
C++17 |
|
118 ms |
199448 KB |
#include<bits/stdc++.h>
using namespace std;
const long long inf = (long long) 1e18 + 10;
const int inf1 = (int) 1e9 + 10;
#define int long long
#define dbl long double
#define endl '\n'
#define sc second
#define fr first
#define mp make_pair
#define pb push_back
#define all(x) x.begin(), x.end()
const int maxn = 303;
int n, m, k, a[maxn], b[maxn], dp[maxn][maxn*maxn];
void solve() {
cin >> n >> m >> k;
for(int i = 1; i <= n; i++)
cin >> a[i];
for(int i = 1; i <= m; i++)
cin >> b[i];
int sma = 0;
for(int i = 1; i <= n; i++) {
sma+= a[i];
if(a[i] < k) {
cout << "Impossible" << endl; return;
}
}
int smb = 0;
for(int i = 1; i <= m; i++) smb+= b[i];
dp[0][0] = 0;
for(int i = 1; i <= smb; i++) dp[0][i] = -inf;
for(int i = 1; i <= m; i++) {
for(int j = 0; j <= smb; j++) {
dp[i][j] = dp[i-1][j];
if(j-b[i] >= 0) dp[i][j] = max(dp[i][j],dp[i-1][j-b[i]]+min(n,b[i]));
}
}
int ans = inf;
for(int i = sma; i <= smb; i++) {
if(dp[m][i] >= n*k) {
cout << i-sma << endl;
return;
}
}
cout << "Impossible" << endl;
}
int32_t main() {
ios::sync_with_stdio(false); cin.tie(0);
// freopen("in.in", "r", stdin);
// freopen("out.out", "w", stdout);
int tt = 1;
// cin >> tt;
while(tt--) {
solve();
}
}
Compilation message
kitchen.cpp: In function 'void solve()':
kitchen.cpp:45:9: warning: unused variable 'ans' [-Wunused-variable]
45 | int ans = inf;
| ^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
340 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 |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
340 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 |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
724 KB |
Output is correct |
10 |
Correct |
1 ms |
724 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
332 KB |
Output is correct |
13 |
Correct |
1 ms |
844 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
76 ms |
136524 KB |
Output is correct |
2 |
Correct |
50 ms |
102220 KB |
Output is correct |
3 |
Correct |
57 ms |
114832 KB |
Output is correct |
4 |
Correct |
97 ms |
195788 KB |
Output is correct |
5 |
Correct |
118 ms |
196324 KB |
Output is correct |
6 |
Correct |
43 ms |
83200 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
968 KB |
Output is correct |
2 |
Correct |
1 ms |
724 KB |
Output is correct |
3 |
Correct |
1 ms |
848 KB |
Output is correct |
4 |
Correct |
1 ms |
980 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
336 KB |
Output is correct |
5 |
Correct |
1 ms |
340 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 |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
724 KB |
Output is correct |
10 |
Correct |
1 ms |
724 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
332 KB |
Output is correct |
13 |
Correct |
1 ms |
844 KB |
Output is correct |
14 |
Correct |
76 ms |
136524 KB |
Output is correct |
15 |
Correct |
50 ms |
102220 KB |
Output is correct |
16 |
Correct |
57 ms |
114832 KB |
Output is correct |
17 |
Correct |
97 ms |
195788 KB |
Output is correct |
18 |
Correct |
118 ms |
196324 KB |
Output is correct |
19 |
Correct |
43 ms |
83200 KB |
Output is correct |
20 |
Correct |
1 ms |
968 KB |
Output is correct |
21 |
Correct |
1 ms |
724 KB |
Output is correct |
22 |
Correct |
1 ms |
848 KB |
Output is correct |
23 |
Correct |
1 ms |
980 KB |
Output is correct |
24 |
Correct |
1 ms |
340 KB |
Output is correct |
25 |
Correct |
52 ms |
99880 KB |
Output is correct |
26 |
Correct |
80 ms |
123816 KB |
Output is correct |
27 |
Correct |
21 ms |
37144 KB |
Output is correct |
28 |
Correct |
52 ms |
101568 KB |
Output is correct |
29 |
Correct |
70 ms |
139068 KB |
Output is correct |
30 |
Correct |
114 ms |
199448 KB |
Output is correct |