yzyyylx @ 2017-11-08 17:30:43
#include<iostream>
#include<cstdio>
#include<queue>
#define ll long long
using namespace std;
ll n;
priority_queue<ll>mx;
priority_queue<ll,vector<ll>,greater<ll> >mn;
int main()
{
ll i,j,k,p,q;
cin>>n>>k;
mx.push(k);
cout<<k<<endl;
for(i=2; i<=n; i+=2)
{
scanf("%lld%lld",&p,&q);
mn.push(max(p,q));
mx.push(min(p,q));
while(mx.top()>mn.top())
{
k=mx.top();
mx.pop();
mx.push(mn.top());
mn.pop();
mn.push(k);
}
printf("%lld\n",mx.top());
}
}