#K40362. Griffin Squad Operations
Griffin Squad Operations
Griffin Squad Operations
Vova is playing the game "Guardians of the Forest", where he manages a squad of mystical creatures called Griffins. Each Griffin has a unique magic number. Vova can perform three types of operations on his squad:
- 1 mi – A Griffin with magic number \( m_i \) joins the squad.
- 2 mi – A Griffin with magic number \( m_i \) leaves the squad. It is guaranteed that at least one such Griffin exists in the squad when this operation is performed.
- 3 – Vova queries the squad to know the current maximum magic number, i.e. \( \max\{ m_i \} \) among all Griffins present.
Note that even though each Griffin is identified by a magic number, duplicate operations may occur resulting in multiple Griffins with the same magic number in the squad.
Your task is to process a list of operations and output the result for every query operation (type 3) in the order they appear.
inputFormat
The input is given via standard input. The first line contains a single integer \( n \) which represents the number of operations. The following \( n \) lines each contain an operation in one of the following formats:
- 1 x — Add a Griffin with magic number \( x \) to the squad.
- 2 x — Remove one occurrence of a Griffin with magic number \( x \) from the squad.
- 3 — Output the maximum magic number among the Griffins currently in the squad.
Operations are provided in the order they need to be executed.
outputFormat
For each query operation (type 3), output the maximum magic number on a separate line. The answers should be printed in the order in which the query operations appear.
## sample6
1 5
1 7
3
2 7
1 3
3
7
5
</p>