Submission #597191

#TimeUsernameProblemLanguageResultExecution timeMemory
597191Trisanu_DasHotel (CEOI11_hot)C++17
100 / 100
1036 ms62880 KiB
#include <iostream> #include <vector> #include <set> #include <algorithm> using namespace std; #define ll long long #define vll vector<long long> #define pll pair<long long, long long> #define sz(x) int(x.size()) int main(){ ios_base::sync_with_stdio(false); cin.tie(NULL); int n, m, o; cin >> n >> m >> o; multiset<pll> rooms; for(int i = 1; i <= n; i++){ ll c, p; cin >> c >> p; rooms.insert({p, c}); } vector<pll> offers(m); for(int j = 0; j < m; j++)cin >> offers[j].second >> offers[j].first; sort(offers.begin(), offers.end(), [] (pll U, pll V){return U.second > V.second;}); ll res = 0; vector<ll> options; for(pll z : offers){ ll capreq = z.first; ll gain = z.second; auto f = rooms.lower_bound({capreq, -1}); if(f == rooms.end()) continue; if(gain > f->second) options.push_back(gain - f->second); rooms.erase(f); } sort(options.begin(), options.end()); for(int i = sz(options)-1; i >= 0 && i >= sz(options)-o; i--) res += options[i]; cout << res << '\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...
#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...