#K49152. Warehouse Inventory Management

    ID: 28579 Type: Default 1000ms 256MiB

Warehouse Inventory Management

Warehouse Inventory Management

You are given a warehouse that initially has no boxes. You must process a series of operations on the warehouse that affect its inventory. There are three types of operations:

  • A w: Add a box with weight w to the warehouse.
  • R q: Remove q boxes with the lowest weights from the warehouse. If there are fewer than q boxes, remove them all.
  • C w: Count and output the number of boxes with weight strictly greater than w.

The operations must be executed in the given order. For every query operation (C), output the result on a new line.

The underlying constraint is that the warehouse inventory is always maintained in sorted order to allow fast queries and removals.

inputFormat

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

  • A w: Add a box with weight w (an integer).
  • R q: Remove q boxes (an integer).
  • C w: Count boxes with weight greater than w (an integer) and output the result.

outputFormat

For every query operation (C), output the result on a new line. If no query operations are provided, the program should output nothing.

## sample
6
A 10
A 20
A 15
C 10
R 2
C 10
2

1

</p>