#K47972. Scoreboard System

    ID: 28317 Type: Default 1000ms 256MiB

Scoreboard System

Scoreboard System

Scoreboard System

You are required to implement a scoreboard system that supports two types of operations:

  • Add Score: Add a given score to a participant's current score.
  • Query: Given a threshold \(T\), count the number of participants whose cumulative score is strictly greater than \(T\).

For a participant i, if the scores from all operations are \(s_{i1}, s_{i2}, \ldots, s_{ik}\), then the cumulative score is given by:

\( s_i = \sum_{j=1}^{k} s_{ij} \)

The query operation returns the count of participants for which \( s_i > T \).

You need to process a series of operations read from stdin and output the results of the query operations to stdout.

inputFormat

The input is given from stdin in the following format:

Q
op_1 [parameters]
op_2 [parameters]
... 
op_Q [parameters]

Here, Q is an integer denoting the number of operations. Each of the following Q lines represents a single operation:

  • If the operation starts with 1, it is an Add Score operation followed by two integers participant_id and score.
  • If the operation starts with 2, it is a Query operation followed by one integer threshold.

For each Query operation, the result should be printed on a new line in stdout.

outputFormat

For each Query operation (operations that start with 2), output a single integer on a separate line representing the number of participants whose cumulative score is strictly greater than the given threshold.

## sample
7
1 1 10
1 2 20
1 1 15
2 10
2 20
1 3 25
2 20
2

1 2

</p>