Submission #938763

#TimeUsernameProblemLanguageResultExecution timeMemory
938763AlebnKitchen (BOI19_kitchen)C++14
31 / 100
2 ms348 KiB
#include <bits/stdc++.h> #define int long long #define M 16 using namespace std; int n, m, k, A = 0, B = 0, res = -1; bool flag = false; vector<int> a, b; signed main() { cin >> n >> m >> k; a = vector<int>(n), b = vector<int>(m); for(int i = 0; i < n; i++) { cin >> a[i]; A += a[i]; if(a[i] < k) flag = true; } for(int i = 0; i < m; i++) { cin >> b[i]; B += b[i]; } // try every subset vector<int> diff; bitset<M> bin; int sus, sum; bool check; for(int i = 0; i < (1 << m); i++) { sum = 0, sus = 0; for(int j = 0; j < m; j++) { if(i & (1 << j)) { sum += b[j]; sus += min(n, b[j]); } } if(sum >= A && sus >= n * k) { if(res == -1) res = sum - A; else res = min(res, sum - A); } } if(flag || res == -1) cout << "Impossible\n"; else cout << res << "\n"; }

Compilation message (stderr)

kitchen.cpp: In function 'int main()':
kitchen.cpp:27:10: warning: unused variable 'check' [-Wunused-variable]
   27 |     bool check;
      |          ^~~~~
#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...