Submission #203996

#TimeUsernameProblemLanguageResultExecution timeMemory
203996mdn2002Kitchen (BOI19_kitchen)C++14
0 / 100
273 ms712 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...