#K1006. Command Collection Manager

    ID: 23162 Type: Default 1000ms 256MiB

Command Collection Manager

Command Collection Manager

You are given a series of commands that modify a collection of unique integers. The collection starts out empty. There are five types of commands:

  • add x: Add the integer x to the collection.
  • delete x: Remove the integer x from the collection (if it exists).
  • query x: Check if x exists in the collection. Output "found" if it exists, otherwise output "not found".
  • max: Print the maximum number in the collection; if the collection is empty, print "empty".
  • min: Print the minimum number in the collection; if the collection is empty, print "empty".

Your task is to process these commands in the order they are given and output the result for each query, max, and min command. For commands that do not require output (add and delete), no output should be produced.

Note: When a command is given that does not change the state (like querying or retrieving the max/min from an empty collection), you must output the response immediately.

The operations are to be performed in sequence as they appear.

inputFormat

The first line of input contains an integer n, the number of commands. Each of the next n lines contains one command, which is one of the following forms: add x, delete x, query x, max, or min.

outputFormat

For each command of type query, max, and min, output the corresponding result on a new line. For query x, output "found" if x exists in the collection, otherwise print "not found". For max and min, output the maximum or minimum number in the collection respectively, or "empty" if the collection is empty.## sample

10
add 5
add 10
query 5
query 7
max
min
delete 5
query 5
max
min
found

not found 10 5 not found 10 10

</p>