#K80577. Integer Set Operations

    ID: 35561 Type: Default 1000ms 256MiB

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. Output YES if it exists, otherwise output NO.
  • get_min: Output the smallest integer in the set. If the set is empty, output None.
  • get_max: Output the largest integer in the set. If the set is empty, output None.

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.

## sample
6
insert 5
insert 3
insert 7
get_min
get_max
find 10
3

7 NO

</p>