Submission #542721

#TimeUsernameProblemLanguageResultExecution timeMemory
542721CaroLindaHotel (CEOI11_hot)C++14
100 / 100
518 ms40660 KiB
#include <bits/stdc++.h> #define pii pair<int,int> #define pb push_back #define ll long long #define mk make_pair #define lp(i,a,b) for(int i = a ; i < b; i++ ) #define sz(x) (int)x.size() #define all(x) x.begin(),x.end() const int MAXN = 5e5+10 ; using namespace std ; int N , M , O ; pair<int,int> vet[MAXN] ; vector<int> freq[MAXN] ; multiset<int> global ; int main(){ ios_base::sync_with_stdio(false ); cin.tie(0) ; cin >> N >> M >> O ; for(int i = 1 ; i <= N ; i++ ){ cin >> vet[i].second >> vet[i].first ; } sort(vet+1, vet+1+N ) ; for(int i = 1 , x , y ; i <= M ; i++ ){ cin >> x >> y ; int it = lower_bound(vet+1, vet+1+N, make_pair(y, -1))-vet ; if(it <= N ) freq[it].push_back(x) ; } vector<int> ans ; for(int i = 1 ; i <= N ; i++ ){ for(auto e : freq[i] ) global.insert(e) ; if(!global.empty()){ ans.push_back( *prev(global.end())-vet[i].second ) ; global.erase( prev(global.end()) ) ; } } sort(all(ans)) ; reverse(all(ans)) ; ll res = 0 ; for(int i = 0 ; i < min(O, sz(ans) ) ; i++ ) res += max(0, ans[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...