Submission #928761

#TimeUsernameProblemLanguageResultExecution timeMemory
928761UmairAhmadMirzaKitchen (BOI19_kitchen)C++17
20 / 100
16 ms600 KiB
#include <bits/stdc++.h> using namespace std; int const N=305; int const inf=1e9; bool dp[N*N]; int main(){ int n,m,k; cin>>n>>m>>k; int arr[n]; int total=0; for(int i=0;i<n;i++){ cin>>arr[i]; total+=arr[i]; } int chef[m]; for(int i=0;i<m;i++) cin>>chef[i]; dp[0]=1; for(int i=0;i<m;i++) for(int sm=(N*m);sm>=chef[i];sm--) dp[sm]|=dp[sm-chef[i]]; for(int i=total;i<=(N*m);i++) if(dp[i]){ cout<<i-total<<endl; return 0; } cout<<"Impossible"<<endl; return 0; }
#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...