Pagini recente » Cod sursa (job #731747) | Cod sursa (job #50952) | Cod sursa (job #906300) | Cod sursa (job #545734) | Cod sursa (job #2417240)
#include<bits/stdc++.h>
using namespace std;
ifstream f("zeap.in");
ofstream g("zeap.out");
int n, x, minim=1e9;
set<int>s, t;
char a[5], p[]="MAX";
int main()
{
while(f>>a)
{
if(a[0]=='I') {f>>x; s.insert(x);}
else if(a[0]=='S')
{
f>>x;
if(s.find(x)!=s.end()) s.erase(x);
else g<<-1<<'\n';
}
else if(a[0]=='C')
{
f>>x;
if(s.find(x)!=s.end()) g<<1<<'\n';
else g<<0<<'\n';
}
else if(a[0]=='M' && a[1]=='A')
{
if(s.size()<2) g<<-1<<'\n';
else
{
set<int>::iterator it=s.begin();
set<int>::iterator it1=s.end();
it1--;
g<<*it1-*it<<'\n';
}
}
else
{
minim=1e9;
if(s.size()<2) g<<-1<<'\n';
else
{
set<int>::iterator it=s.begin();
it++;
set<int>::iterator it2=s.end();
it2--;
for(set<int>::iterator it1=s.begin(); it1!=it2, it!=s.end(); it1++, it++)
if(minim>*it-*it1) minim=*it-*it1;
g<<minim<<'\n';
}
}
}
return 0;
}