#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define ll long long
const ll sz=1e5+5, szz=1e6+5;
ll a[sz], b[sz], dp[szz], suma, sumb, f=1;
int main()
{
ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
ll n, m, k;
cin>>n>>m>>k;
for(int i=1; i<szz; i++) dp[i]=-1;
for(int i=1; i<=n; i++){
cin>>a[i];
if(a[i]<k) f=0;
}
for(int i=1; i<=m; i++){
cin>>b[i];
}
if(!f){ cout<<"Impossible"; return 0;}
for(int i=1; i<=m; i++){
sumb+=b[i];
for(int j=sumb-b[i]; j>=0; j--){
if(dp[j]!=-1){
dp[j+b[i]]=max(dp[j+b[i]], dp[j]+min(n, b[i]));
}
}
}
for(int i=suma; i<sz; i++){
if(dp[i]>=n*k){
cout<<dp[i]-suma;
return 0;
}
}
cout<<"Impossible";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
8796 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
8796 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
9 ms |
8796 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
8792 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
8796 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |