제출 #203998

#제출 시각아이디문제언어결과실행 시간메모리
203998mdn2002Kitchen (BOI19_kitchen)C++14
0 / 100
266 ms4344 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]; memset(dp,-1,sizeof dp); dp[0]=0; for(int i=0;i<m;i++) { for(int j=1000000-b[i];j>=0;j--) { if(dp[j]!=-1)dp[j+b[i]]=max(dp[j]+1,dp[j+b[i]]); } } for(int i=sum;i<=1000000;i++) { if(dp[i]>=k) { 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...