Submission #938726

#TimeUsernameProblemLanguageResultExecution timeMemory
938726vjudge1Kitchen (BOI19_kitchen)C++17
9 / 100
77 ms428 KiB
#include <bits/stdc++.h> #define int long long #define M 301 using namespace std; int n, m, k, A = 0, B = 0, res = LLONG_MAX; bool flag = false; vector<int> a, b; vector<vector<bool>> dp; 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]; } if(k >= 1) { // try every subset vector<int> diff; bitset<M> bin; int temp, sum; bool check; for(int i = 0; i < (1 << m); i++) { bin = bitset<M>(i), diff = vector<int>(n, k), sum = 0, check = true; for(int j = 0; j < M; j++) { if(bin[j]) { sum += b[j]; temp = b[j]; for(int k = 0; k < n && temp; k++) { if(diff[k]) { diff[k]--; temp--; } } } } for(int j = 0; j < n; j++) { if(diff[j]) { check = false; break; } } if(check && sum >= A) res = min(res, sum - A); } if(flag || res == LLONG_MAX) cout << "Impossible\n"; else cout << res << "\n"; return 0; } }
#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...