Submission #646196

#TimeUsernameProblemLanguageResultExecution timeMemory
646196berrKitchen (BOI19_kitchen)C++17
100 / 100
56 ms640 KiB
#include <bits/stdc++.h> using namespace std; int kp[300*300+5]; int32_t main() { ios_base::sync_with_stdio(false); cin.tie(0); int n, m, k, ans=1e9,flag=1, ans2=0, sum2=0; cin>>n>>m>>k; vector<int> a(n), b(m), c(n); ans=0; for(int i=0; i<n; i++) cin>>a[i], ans+=a[i]; for(int i=0; i<m; i++) cin>>b[i]; for(int i=0; i<n; i++) if(a[i]<k) flag=0; for(int i=0; i<m; i++) { for(int l=300*300; l>=0; l--) { if((l==0)||kp[l]) { kp[l+b[i]]=max(kp[l]+min(b[i], n), kp[l+b[i]]); } } } int br=1; for(int l=ans; l<=300*300&&br; l++) { if(kp[l]>=n*k) ans-=l, br=0; } if(flag&&ans<=0) cout<<-ans; else cout<<"Impossible"; }

Compilation message (stderr)

kitchen.cpp: In function 'int32_t main()':
kitchen.cpp:8:34: warning: unused variable 'ans2' [-Wunused-variable]
    8 |     int n, m, k, ans=1e9,flag=1, ans2=0, sum2=0; cin>>n>>m>>k;
      |                                  ^~~~
kitchen.cpp:8:42: warning: unused variable 'sum2' [-Wunused-variable]
    8 |     int n, m, k, ans=1e9,flag=1, ans2=0, sum2=0; cin>>n>>m>>k;
      |                                          ^~~~
#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...