Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- typedef long long int ll;
- typedef pair<ll,pair<ll,ll>> pii;
- int main(){
- ll n;
- priority_queue<pii,vector<pii>,greater<pii>> q;
- //2out 1in
- scanf("%lld",&n);
- for(ll i=0;i<n;i++){
- ll a,b,x;
- scanf("%lld %lld %lld",&a,&b,&x);
- q.push({a,{1,-x}});
- q.push({b,{2,x}});
- }
- ll now_H=-99;
- multiset<ll> sett;
- sett.insert(0);
- while(!q.empty()){
- ll now=q.top().first, x=q.top().second.first, h=q.top().second.second;
- q.pop();
- //printf("[%lld %lld %lld]\n",now,x,h);
- if(x==1){
- sett.insert(-h);
- }
- else{
- sett.erase(sett.find(h));
- }
- auto itr = sett.end();
- itr--;
- if(*itr!=now_H){
- printf("%lld %lld\n",now,*itr);
- now_H=*itr;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement