Submission #125942

#TimeUsernameProblemLanguageResultExecution timeMemory
125942The_WolfpackKitchen (BOI19_kitchen)C++14
100 / 100
31 ms760 KiB
#include <bits/stdc++.h> using namespace std; const int NMAX=305; int n,m,k,sum; int a[NMAX],b[NMAX],dp[NMAX*NMAX+10]; int main() { ios_base::sync_with_stdio(false); cin>>n>>m>>k; for(int i=1;i<=n;i++) cin>>a[i]; for(int i=1;i<=n;i++) { if(a[i]<k) { cout<<"Impossible"<<endl; return 0; } sum+=a[i]; } for(int j=1;j<=m;j++) cin>>b[j]; memset(dp, -NMAX*NMAX-1999, sizeof(dp)); dp[0]=0; for(int i=1;i<=m;i++) for(int j=NMAX*NMAX;j>=b[i];j--) { dp[j]=max(dp[j],dp[j-b[i]]+min(n,b[i])); } for(int t=sum;t<=NMAX*NMAX;t++) { if(dp[t]>=n*k) { cout<<t-sum<<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...