#K46367. Operation Processor

    ID: 27961 Type: Default 1000ms 256MiB

Operation Processor

Operation Processor

You are given an initially empty list of integers. Your task is to process a series of operations on this list. The operations are described as follows:

  1. add x: Add the integer (x) to the list.
  2. remove x: Remove one occurrence of the integer (x) from the list. If (x) is not present, do nothing.
  3. max: Print the maximum integer in the list. If the list is empty, print EMPTY.

You will be given a number of operations, and you must process each operation in the order given. For every max operation, output the result on a new line.

The problem tests your ability to effectively manage dynamic data and perform basic queries on it.

inputFormat

The first line of the input contains a single integer (T) ((1 \le T \le 10^5)), representing the number of operations. Each of the following (T) lines contains one of the following commands:

  • add x where \(x\) is an integer.
  • remove x where \(x\) is an integer.
  • max

Note: There is a space between the command and the integer for the add and remove operations.

outputFormat

For each max operation, output the maximum integer present in the list on a new line. If the list is empty during a max operation, output EMPTY.## sample

4
add 10
max
remove 10
max
10

EMPTY

</p>