# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
745871 |
2023-05-21T08:58:52 Z |
vjudge1 |
Kitchen (BOI19_kitchen) |
C++17 |
|
140 ms |
100708 KB |
#include <bits/stdc++.h>
using namespace std;
#define InTheNameOfGod ios::sync_with_stdio(0);cin.tie(0); cout.tie(0);
using ll = long long;
const int maxN = 2e5 + 5;
const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
int main() {
/*#ifndef ONLINE_JUDGE
freopen("../../input.txt", "r", stdin);
freopen("../../output.txt", "w", stdout);
#endif*/
InTheNameOfGod;
int n,m,k;
cin >>n >> m >> k;
vector<int> a(n),b(m);
int s = 0, s2 = 0, must = (n)*(k-1);
bool ok = 0;
for(int i = 0; i < n; i++) {
cin >> a[i];
s2 += a[i];
if(a[i] < k) ok = 1;
}
for(int &i : b) {
cin >> i;
s += i;
}
if(ok || m < k) {
cout << "Impossible\n";
return 0;
}
vector<vector<int> > dp(m+1, vector<int> (s+1, INF));
int mo = INF;
dp[0][0] = n*k;
for(int i = 0; i < m; i++) {
for(int j = 0; j <= s; j++) {
if(dp[i][j] != INF) {
dp[i+1][j] = min(dp[i+1][j], dp[i][j]);
if(j + b[i] >= s2 && dp[i][j] - min(b[i], n) <= 0) mo = min(mo, j+b[i] - s2);
dp[i+1][j+b[i]] = min(dp[i+1][j+b[i]], dp[i][j] - min(b[i], n));
}
//cout << i << ", " << j << ": " << dp[i][j] << endl;
}
}
if(mo == INF) cout << "Impossible" << endl;
else cout << mo << endl;
return 0;
}
Compilation message
kitchen.cpp: In function 'int main()':
kitchen.cpp:23:25: warning: unused variable 'must' [-Wunused-variable]
23 | int s = 0, s2 = 0, must = (n)*(k-1);
| ^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
240 KB |
Output is correct |
8 |
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 |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
240 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
468 KB |
Output is correct |
10 |
Correct |
1 ms |
468 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
532 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
68 ms |
68844 KB |
Output is correct |
2 |
Correct |
51 ms |
51404 KB |
Output is correct |
3 |
Correct |
86 ms |
57104 KB |
Output is correct |
4 |
Correct |
140 ms |
98252 KB |
Output is correct |
5 |
Correct |
130 ms |
98508 KB |
Output is correct |
6 |
Correct |
39 ms |
41492 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
468 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
468 KB |
Output is correct |
4 |
Correct |
1 ms |
468 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
240 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
468 KB |
Output is correct |
10 |
Correct |
1 ms |
468 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
532 KB |
Output is correct |
14 |
Correct |
68 ms |
68844 KB |
Output is correct |
15 |
Correct |
51 ms |
51404 KB |
Output is correct |
16 |
Correct |
86 ms |
57104 KB |
Output is correct |
17 |
Correct |
140 ms |
98252 KB |
Output is correct |
18 |
Correct |
130 ms |
98508 KB |
Output is correct |
19 |
Correct |
39 ms |
41492 KB |
Output is correct |
20 |
Correct |
1 ms |
468 KB |
Output is correct |
21 |
Correct |
1 ms |
340 KB |
Output is correct |
22 |
Correct |
1 ms |
468 KB |
Output is correct |
23 |
Correct |
1 ms |
468 KB |
Output is correct |
24 |
Correct |
0 ms |
212 KB |
Output is correct |
25 |
Correct |
43 ms |
50352 KB |
Output is correct |
26 |
Correct |
56 ms |
62164 KB |
Output is correct |
27 |
Correct |
28 ms |
18388 KB |
Output is correct |
28 |
Correct |
76 ms |
51544 KB |
Output is correct |
29 |
Correct |
101 ms |
70004 KB |
Output is correct |
30 |
Correct |
137 ms |
100708 KB |
Output is correct |