Submission #535480

#TimeUsernameProblemLanguageResultExecution timeMemory
535480new_accKitchen (BOI19_kitchen)C++14
20 / 100
25 ms664 KiB
#include<bits/stdc++.h> #define fi first #define se second using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<ll> vl; const int N=300*300+10; int pl[N]; int a[N],b[N]; void solve(){ int n,m,k; cin>>n>>m>>k; int sum1=0,sum2=0,sum3=0; for(int i=1;i<=n;i++){ cin>>a[i]; sum1+=a[i]; } for(int i=1;i<=m;i++){ cin>>b[i]; sum2+=b[i]; sum3+=min(n,b[i]); } if(sum2<sum1 or sum3<n*k){ cout<<"Impossible\n"; return; } for(int i=1;i<=300*300;i++) pl[i]=-1; for(int i=1;i<=m;i++){ for(int j=300*300;j>=0;j--) if(j+b[i]<=300*300 and pl[j]!=-1) pl[j+b[i]]=max(pl[j+b[i]],pl[j]+min(b[i],n)); } for(int i=sum1;i<=300*300;i++){ if(pl[i]>=n*k){ cout<<i-sum1<<"\n"; return; } } } int main(){ solve(); }
#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...