#C1930. Library Management System for Checked-Out Books

    ID: 45190 Type: Default 1000ms 256MiB

Library Management System for Checked-Out Books

Library Management System for Checked-Out Books

You are required to implement a library management system that tracks checked-out book IDs. The system maintains a collection of unique book IDs in sorted order and supports the following operations:

  • add X: Adds the book ID X to the checked-out list.
  • remove X: Removes the book ID X from the list if it exists.
  • check X: Checks whether the book ID X is in the list. Output True if present and False otherwise.
  • kth K: Returns the Kth smallest book ID in the checked-out list. If K is out of bounds, output -1.

Internally, you should maintain the list in sorted order. For kth queries, note that the list is 1-indexed. For example, if the list is \( [10, 15, 20] \), then the 2nd smallest is 15.

inputFormat

The first line contains an integer Q representing the number of operations. The next Q lines each contain an operation in one of the following formats:

  • add X
  • remove X
  • check X
  • kth K

Here, X and K are integers. For check and kth operations, you must output the corresponding result.

outputFormat

For each check and kth operation, output the result on a new line. For a check operation, output either True or False. For a kth operation, output the kth smallest book ID or -1 if the query is invalid.

## sample
6
add 10
add 20
check 10
kth 2
remove 20
check 20
True

20 False

</p>