#include <bits/stdc++.h>
using namespace std;
int const N=305;
int const inf=1e9;
bool dp[N*N];
int main(){
int n,m,k;
cin>>n>>m>>k;
int arr[n];
int total=0;
for(int i=0;i<n;i++){
cin>>arr[i];
total+=arr[i];
}
int chef[m];
for(int i=0;i<m;i++)
cin>>chef[i];
dp[0]=1;
for(int i=0;i<m;i++)
for(int sm=(N*m);sm>=chef[i];sm--)
dp[sm]|=dp[sm-chef[i]];
for(int i=total;i<=(N*m);i++)
if(dp[i]){
cout<<i-total<<endl;
return 0;
}
cout<<"Impossible"<<endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
344 KB |
Output is correct |
2 |
Correct |
9 ms |
600 KB |
Output is correct |
3 |
Correct |
16 ms |
344 KB |
Output is correct |
4 |
Correct |
16 ms |
344 KB |
Output is correct |
5 |
Correct |
14 ms |
348 KB |
Output is correct |
6 |
Correct |
8 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |