Submission #443219

#TimeUsernameProblemLanguageResultExecution timeMemory
443219prvocisloHotel (CEOI11_hot)C++17
100 / 100
526 ms39988 KiB
#include <bits/stdc++.h> typedef long long ll; using namespace std; struct room { ll c, p; }; bool cmproom(const room &a, const room &b) { if (a.c == b.c) return a.p < b.p; return a.c < b.c; } bool cmpoffer(const room &a, const room &b) { return a.p < b.p; } int main() { ios::sync_with_stdio(false); cin.tie(0); int n, m, k; cin >> n >> m >> k; vector<room> r(n), o(m); for (int i = 0; i < n; i++) cin >> r[i].c >> r[i].p; sort(r.begin(), r.end(), cmproom); for (int i = 0; i < m; i++) cin >> o[i].c >> o[i].p; sort(o.begin(), o.end(), cmpoffer); multiset<ll, greater<ll>> best; vector<ll> v; for (int i = 0, j = 0; i < n; i++) { while (j < m && o[j].p <= r[i].p) best.insert(o[j++].c); if (!best.empty()) { ll x = *best.begin(); best.erase(best.begin()); v.push_back(x - r[i].c); } } sort(v.begin(), v.end(), greater<ll>()); ll ans = 0, sum = 0; for (int i = 0; i < min((int)v.size(), k); i++) sum += v[i], ans = max(ans, sum); 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...
#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...