Submission #928777

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