# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1005434 |
2024-06-22T12:41:14 Z |
vjudge1 |
Kitchen (BOI19_kitchen) |
C++17 |
|
1 ms |
856 KB |
#include <bits/stdc++.h>
using namespace std;
const int inf = 1e18;
int n, m, k, res;
int s1, s2, s3, s4, s5, s6, s7, l;
int dp[100001];
int b[301];
int main(){
cin >> n >> m >> k;
s7 = inf;
for(int i = 1; i <= n; i++){
cin >> l;
s2 += l;
s7 = min(s7, l);
}
for(int i = 1; i <= m; i++){
cin >> b[i];
s4 += b[i];
}
for(int i = 0; i <= s4; i++)
dp[i] = -inf;
if(s7 < k){
cout << "Imposible";
}
dp[0] = 0;
for(int i = 1; i <= m; i++){
for(int j = s4 - b[j]; j >= 0; --j){
if(dp[j] != inf){
dp[j + b[i]] = max(dp[j + b[i]], dp[j] + min(b[i], n));
}
s3 = inf;
for(int j = s2; j <= s4; j++){
if(dp[j] >= n * k) s3 = min(s3, j - s2);
}
}
}
if(s3 != inf) cout << s3;
else cout << "Impossible";
}
Compilation message
kitchen.cpp:3:17: warning: overflow in conversion from 'double' to 'int' changes value from '1.0e+18' to '2147483647' [-Woverflow]
3 | const int inf = 1e18;
| ^~~~
kitchen.cpp: In function 'int main()':
kitchen.cpp:20:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
20 | for(int i = 0; i <= s4; i++)
| ^~~
kitchen.cpp:22:9: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
22 | if(s7 < k){
| ^~
kitchen.cpp:27:33: warning: array subscript -1 is below array bounds of 'int [301]' [-Warray-bounds]
27 | for(int j = s4 - b[j]; j >= 0; --j){
| ~~~^
kitchen.cpp:7:5: note: while referencing 'b'
7 | int b[301];
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
344 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
344 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
856 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
0 ms |
348 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
344 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |