Pagini recente » Cod sursa (job #3248689) | Cod sursa (job #1770363) | Cod sursa (job #1334823) | Cod sursa (job #808074) | Cod sursa (job #2757953)
#include <bits/stdc++.h>
using namespace std;
ifstream fin( "zeap.in" );
ofstream fout( "zeap.out" );
const int INF = 2000000000;
set <int> s;
int main()
{
string input;
while( fin >> input ) {
if( input == "MAX" )
if( s.size() < 2 ) fout << "-1\n";
else fout << *s.rbegin() - *s.begin() << '\n';
if( input == "MIN" )
if( s.size() < 2 ) fout << "-1\n";
else {
int minn = INF;
for( set<int>::iterator it = s.begin(); it != s.end(); it++ ){
set<int>::iterator it2 = it;
it2++;
if( it2 != s.end() )
minn = min( minn, *it2 - *it );
}
fout << minn << '\n';
}
int x;
if( input[0] == 'I' ) {
fin >> x;
s.insert( x );
}
if( input[0] == 'S' ) {
fin >> x;
set<int>::iterator it = s.find( x );
if( it == s.end() )
fout << "-1\n";
else
s.erase( it );
}
if( input[0] == 'C' ) {
fin >> x;
set<int>::iterator it = s.find( x );
fout << ( it != s.end() ) << '\n';
}
}
return 0;
}