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[1000000],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];
dp[0]=1;
for(int i=0;i<m;i++)
{
for(int j=1000000-b[i];j>=0;j--)
{
if(dp[j])dp[j+b[i]]=1;
}
}
for(int i=sum;i<=1000000;i++)
{
if(dp[i])
{
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... |