This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
const int NMAX=305;
int n,m,k,sum;
int a[NMAX],b[NMAX],dp[NMAX*NMAX+10];
int main()
{
ios_base::sync_with_stdio(false);
cin>>n>>m>>k;
for(int i=1;i<=n;i++) cin>>a[i];
for(int i=1;i<=n;i++)
{
if(a[i]<k)
{
cout<<"Impossible"<<endl;
return 0;
}
sum+=a[i];
}
for(int j=1;j<=m;j++) cin>>b[j];
memset(dp, -NMAX*NMAX-1999, sizeof(dp));
dp[0]=0;
for(int i=1;i<=m;i++) for(int j=NMAX*NMAX;j>=b[i];j--)
{
dp[j]=max(dp[j],dp[j-b[i]]+min(n,b[i]));
}
for(int t=sum;t<=NMAX*NMAX;t++)
{
if(dp[t]>=n*k)
{
cout<<t-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... |