제출 #743272

#제출 시각아이디문제언어결과실행 시간메모리
743272Dan4LifeHotel (CEOI11_hot)C++17
100 / 100
1820 ms58768 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define sz(a) (int)a.size() const int mxN = (int)5e5+10; using ar = array<int,2>; ar a[mxN]; int n, m, k, x, y; int32_t main(){ cin >> n >> m >> k; multiset<pair<int,int>> Ms; for(int i = 0; i < n; i++) 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 sz(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...