#include <bits/stdc++.h>
using namespace std;
int const N=42;
int const inf=1e9;
bool dp[N*N][N*N];
int n,m,k;
int main(){
cin>>n>>m>>k;
int arr[n];
int total=0;
for(int i=0;i<n;i++){
cin>>arr[i];
total+=arr[i];
if(arr[i]<k){
cout<<"Impossible"<<endl;
return 0;
}
}
int chef[m];
for(int i=0;i<m;i++)
cin>>chef[i];
dp[0][0]=1;
for(int i=0;i<m;i++)
for(int tot=(N*m);tot>=chef[i];tot--)
for(int uni=min(chef[i],n);uni<=tot;uni++)
dp[tot][uni]|=dp[tot-chef[i]][uni-min(chef[i],n)];
for(int tot=total;tot<=(N*m);tot++)
for(int uni=(k*n);uni<=tot;uni++)
if(dp[tot][uni]){
cout<<tot-total<<endl;
return 0;
}
cout<<"Impossible"<<endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
348 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
28 ms |
3164 KB |
Output is correct |
2 |
Correct |
27 ms |
3164 KB |
Output is correct |
3 |
Correct |
26 ms |
3164 KB |
Output is correct |
4 |
Correct |
29 ms |
3164 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |