Submission #259416

#TimeUsernameProblemLanguageResultExecution timeMemory
259416islingrHotel (CEOI11_hot)C++17
100 / 100
1262 ms49504 KiB
#include <bits/stdc++.h> using namespace std; #define rep(i, a, b) for (auto i = (a); i < (b); ++i) #define rall(x) (x).rbegin(), (x).rend() int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int n, m, o; cin >> n >> m >> o; multiset<pair<int, int>> room; rep(i, 0, n) { int p, c; cin >> c >> p; room.insert({p, c}); } vector<pair<int, int>> offer(m); rep(i, 0, m) { int v, d; cin >> v >> d; offer[i] = {v, d}; } sort(rall(offer)); vector<int> res; for (auto [v, d] : offer) { auto it = room.lower_bound({d, 0}); if (it == end(room)) continue; res.push_back(v - it->second); room.erase(it); } sort(rall(res)); int64_t ans = 0; rep(i, 0, min(o, int(res.size()))) { if (res[i] <= 0) break; ans += res[i]; } cout << ans; }
#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...