#include <bits/stdc++.h>
using namespace std;
const int maxn=310;
int v[maxn], dp[maxn][maxn*maxn];
int main()
{
ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
int n, m, k; cin >> n >> m >> k;
int sum=0;
for(int i=1;i<=n;i++){
int a; cin >> a;
sum+=a;
if(a<k){
cout << "Impossible" << endl;
return 0;
}
}
for(int i=1;i<=m;i++) cin >> v[i];
for(int i=1;i<=m;i++){
for(int j=0;j<v[i];j++) dp[i][j]=dp[i-1][j];
for(int j=0;j<maxn*maxn-v[i];j++) dp[i][j+v[i]]=max(dp[i-1][j+v[i]],dp[i-1][j]+min(v[i],n));
}
for(int i=sum;i<maxn*maxn;i++){
if((dp[m][i]/n)>=k){
cout << i-sum << endl;
return 0;
}
}
cout << "Impossible" << endl;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |