#include<iostream>
#include<algorithm>
#include<set>
using namespace std;
int n;
set<int>ku;
int main(){
int opt,temp;
cin>>n;
while(n--){
cin>>opt>>temp;
if(opt==1){
if(ku.find(temp)!=ku.end()) cout<<"Already Exist"<<endl;
else ku.insert(temp);
}
else if(ku.empty()){
cout<<"Empty"<<endl;
}
else{
set<int>::iterator i=ku.lower_bound(temp),j=i;
if(j!=ku.begin())j--;
if(i!=ku.end()&&(*i)-temp>=temp-(*j)) i=j;
cout<<*i<<endl;
ku.erase(i);
}
}
return 0;
}
下面时AC的
if(i!=ku.end()&&(*i)-temp<temp-(*j)) j=i;
cout<<*j<<endl;
ku.erase(j);