#K80577. Integer Set Operations
Integer Set Operations
Integer Set Operations
You are given a set of integers that starts out empty. Your task is to implement a data structure to support the following operations:
insert x
: Insert the integer \(x\) into the set.remove x
: Remove the integer \(x\) from the set if present.find x
: Check whether the integer \(x\) exists in the set. OutputYES
if it exists, otherwise outputNO
.get_min
: Output the smallest integer in the set. If the set is empty, outputNone
.get_max
: Output the largest integer in the set. If the set is empty, outputNone
.
The operations \(insert(x)\), \(remove(x)\), and \(find(x)\) should be performed according to the commands specified in the input. Ensure that for each query operation (find
, get_min
, or get_max
), the result is printed to stdout on a separate line.
It is guaranteed that the input follows the format described below.
inputFormat
The first line of input contains an integer \(n\) indicating the number of operations.
Each of the following \(n\) lines contains a command in one of the following formats:
insert x
remove x
find x
get_min
get_max
Here, \(x\) is an integer.
outputFormat
For every command find
, get_min
, or get_max
, output the result on a new line. For find
, output either YES
or NO
; for get_min
and get_max
, output the corresponding integer, or None
if the set is empty.
6
insert 5
insert 3
insert 7
get_min
get_max
find 10
3
7
NO
</p>