Submission #204000

#TimeUsernameProblemLanguageResultExecution timeMemory
204000mdn2002Kitchen (BOI19_kitchen)C++14
100 / 100
37 ms716 KiB
#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 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...