#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;
}
}
memset(dp,-1,sizeof(dp));
dp[0][0]=0;
for(int i=1;i<=m;i++) cin >> v[i];
for(int i=1;i<=m;i++){
for(int j=0;j<maxn*maxn;j++){
dp[i][j]=dp[i-1][j];
if(j>=v[i]&&dp[i-1][j-v[i]]!=-1) dp[i][j]=max(dp[i][j],dp[i-1][j-v[i]]+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... |