RT 学的第一篇题解```
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n,x,y;
map<int,int> m;
auto it,it2;
int main()
{
cin>>n;
for(int i=1;i<=n;i++){
cin>>x>>y;
if(x==1){
if(m[y]==0)m[y]++;
else {
cout<<"Already Exist"<<endl;
}
}
else{
if(m.empty())cout<<"Empty";
else if(m[y]==1){
cout<<y<<endl;
m.erase(y);
}
else {
m[y]=1;
it=m.find(y);
it2=it;
it++;
if(it2==m.begin()){
cout<<it->first<<endl;
m.erase(it);
}
else if(it==m.end()){
cout<<(--it2)->first<<endl;
m.erase(it2);
}
else if (y-(--it2)->first > it->first-y) {
cout<<it->first<<endl;
m.erase(it);
}
else {
cout<<it2->first<<endl;
m.erase(it2);
}
m.erase(y);
}
}
}
}