#C6409. List Operations and Maximum Query

    ID: 50166 Type: Default 1000ms 256MiB

List Operations and Maximum Query

List Operations and Maximum Query

In this problem, you are given a series of operations to perform on a list of integers. The operations are of three types:

  • 1 x: Append the integer \(x\) to the list.
  • 2 x: Remove one occurrence of the integer \(x\) from the list. If \(x\) is not in the list, do nothing.
  • 3: Print the maximum integer currently in the list. If the list is empty, output \(-1\).

The program should read input from stdin and output the results of every query (operation type 3) to stdout, each on a new line.

inputFormat

The first line contains an integer (n), representing the total number of operations. Each of the following (n) lines contains an operation in one of the following formats:

  • 1 x
  • 2 x
  • 3

For example:

6
1 3
1 5
1 -1
3
2 5
3

outputFormat

For every operation of type 3, print the maximum integer in the list on its own line. If the list is empty at the moment of the query, print (-1).## sample

6
1 3
1 5
1 -1
3
2 5
3
5

3

</p>