Submission #567293

#TimeUsernameProblemLanguageResultExecution timeMemory
567293haxormanKitchen (BOI19_kitchen)C++14
0 / 100
1 ms212 KiB
#include <bits/stdc++.h> using namespace std; const int mxN = 307; int a[mxN], b[mxN], og_a[mxN], og_b[mxN]; int32_t main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int n, m, k; cin >> n >> m >> k; if (m < k) { cout << "Impossible\n"; exit(0); } for (int i = 0; i < n; ++i) { cin >> a[i]; og_a[i] = a[i]; } for (int i = 0; i < m; ++i) { cin >> b[i]; og_b[i] = b[i]; } sort(b, b + m); int ind = 0; set<int> used; for (int i = 0; i < n; ++i) { for (int j = ind; j < ind + k; ++j) { if (j >= m) { cout << "Impossible\n"; exit(0); } used.insert(j); b[j]--; a[i]--; } if (a[i] < 0) { cout << "Impossible\n"; exit(0); } if (!b[ind]) { ++ind; } while (a[i]) { used.insert(ind); if (a[i] >= b[ind]) { a[i] -= b[ind]; ++ind; } else { b[ind] -= a[i]; a[i] = 0; } } } int sum_b = 0; for (auto x : used) { sum_b += og_b[x]; } for (int i = 0; i < n; ++i) { sum_b -= og_a[i]; } cout << sum_b << "\n"; }
#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...