제출 #771574

#제출 시각아이디문제언어결과실행 시간메모리
771574NeroZeinKitchen (BOI19_kitchen)C++17
9 / 100
64 ms320 KiB
#include "bits/stdc++.h" #define int long long using namespace std; #ifdef Nero #include "Deb.h" #else #define deb(...) #endif signed main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int n, m, k; cin >> n >> m >> k; vector<int> a(n); for (int i = 0; i < n; ++i) { cin >> a[i]; } vector<int> b(m); for (int i = 0; i < m; ++i) { cin >> b[i]; } int tot = accumulate(a.begin(), a.end(), 0ll); int ans = INT_MAX; for (int mask = 1; mask < (1 << m); ++mask) { int s = 0; vector<int> cnt(n); for (int i = 0; i < m; ++i) { if (mask >> i & 1) { s += b[i]; for (int j = 0, c = 0; j < n && c < b[i]; ++j) { if (cnt[j] < k && cnt[j] < a[j]) { c++; cnt[j]++; } } } } if (s < tot) { continue; } if (*min_element(cnt.begin(), cnt.end()) >= k) { ans = min(ans, s - tot); } } if (ans == INT_MAX) { cout << "Impossible" << '\n'; } else { cout << ans << '\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...