Submission #862310

#TimeUsernameProblemLanguageResultExecution timeMemory
862310iskhakkutbilimKitchen (BOI19_kitchen)C++17
9 / 100
2 ms456 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define ff first #define ss second #define all(a) a.begin(), a.end() const int mod = 1e17; main(){ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, m, k; vector<int> a, b; cin >> n >> m >> k; a.resize(n); for(auto &e : a) cin >> e; b.resize(m); for(auto &e : b) cin >> e; vector<int> B = b; if(a[0] < k){ cout << "Impossible"; return 0; } int ans = mod; for(int all = 0; all < (1<<m); all++){ if(__builtin_popcount(all) < k) continue; int s = 0; b = B; for(auto x : a){ int K = 0; for(int i = 0;i < m; i++){ if(all & (1<<i) && b[i] > 0 && K < k){ b[i]--, K++, x--; } } if(K != k){ s = mod; break; } for(int i = 0;i < m; i++){ if(all & (1<<i) && x > 0){ if(b[i] >= x){ b[i]-= x; x = 0; }else{ x-= b[i]; b[i] = 0; } } } if(x != 0){ s = mod; break; } } for(int i = 0;i < m; i++){ if(all & (1<<i)){ s+= b[i]; } } ans = min(ans, s); } if(ans >= mod){ cout << "Impossible"; return 0; } cout << ans; return 0; }

Compilation message (stderr)

kitchen.cpp:10:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   10 | main(){
      | ^~~~
#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...