Submission #493007

#TimeUsernameProblemLanguageResultExecution timeMemory
493007wiwihoKitchen (BOI19_kitchen)C++14
9 / 100
1 ms460 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; void nosol(){ cout << "Impossible\n"; exit(0); } int main(){ ios_base::sync_with_stdio(false); cin.tie(0); cerr.tie(0); int n, m, k; cin >> n >> m >> k; vector<int> a(n + 1); vector<int> b(m + 1); ll sa = 0, sb = 0; for(int i = 1; i <= n; i++) cin >> a[i], sa += a[i]; for(int i = 1; i <= m; i++) cin >> b[i], sb += b[i]; sort(b.begin() + 1, b.end()); if(k > m || sa > sb){ nosol(); } for(int i = 1; i <= n; i++) if(a[i] < k) nosol(); assert(m <= 2); if(k == 1){ if(sa <= b[1]) cout << b[1] - sa << "\n"; else if(sa <= b[2]) cout << b[2] - sa << "\n"; else cout << b[1] + b[2] - sa << "\n"; return 0; } if(n > b[1]) nosol(); cout << b[1] + b[2] - sa << "\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...