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;
int n,m,k,a[305],b[305],dp[90005],sum=0;
int main()
{
cin>>n>>m>>k;
for(int i=0;i<n;i++)
{
cin>>a[i];
sum+=a[i];
if(a[i]<k)
{
cout<<"Impossible";
return 0;
}
}
for(int i=0;i<m;i++)cin>>b[i];
memset(dp,-1,sizeof dp);
dp[0]=0;
for(int i=0;i<m;i++)
{
for(int j=90005-b[i];j>=0;j--)
{
if(dp[j]!=-1)dp[j+b[i]]=max(dp[j]+min(n,b[i]),dp[j+b[i]]);
}
}
int mn=n*k;
for(int i=sum;i<=90005;i++)
{
if(dp[i]>=mn)
{
cout<<i-sum;
return 0;
}
}
cout<<"Impossible"<<endl;
}
# | 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... |