Submission #743278

#TimeUsernameProblemLanguageResultExecution timeMemory
743278Dan4LifeHotel (CEOI11_hot)C++17
100 / 100
1870 ms39540 KiB
#include <bits/stdc++.h> using namespace std; #define int long long const int mxN = (int)5e5+10; int n, m, k, x, y; array<int,2> a[mxN]; int32_t main(){ cin >> n >> m >> k; multiset<pair<int,int>> Ms; while(n--) cin >> x >> y, Ms.insert({y,x}); for(int i = 0; i < m; i++) cin >> a[i][0] >> a[i][1]; multiset<int,greater<>> S; int ans = 0; sort(a,a+m); for(int i = m-1; i >= 0; i--){ auto itr=Ms.lower_bound({a[i][1],0}); if(itr!=end(Ms) and itr->second < a[i][0]) S.insert(a[i][0]-itr->second), Ms.erase(itr); } while(k-- and size(S)) ans+=max(0ll,*begin(S)), S.erase(begin(S)); 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...