#K53442. Contest Score Management System

    ID: 29532 Type: Default 1000ms 256MiB

Contest Score Management System

Contest Score Management System

This problem requires you to implement a contest management system where participants can be added, updated, and queried for their cumulative scores.

You will process a sequence of operations. Each operation is one of the following commands:

  • ADD P S: Add a new participant with ID \(P\) and an initial score \(S\). If the participant already exists, increment their score by \(S\).
  • UPDATE P S: Update the score of participant \(P\) to \(S\). If the participant does not exist, add them with score \(S\).
  • QUERY L R: Compute and return the total score of all participants whose IDs are in the range \([L, R]\) (inclusive).

Your task is to process the operations sequentially and output the result for each QUERY command.

inputFormat

The first line contains an integer \(n\) representing the number of operations. The next \(n\) lines each contain one operation. Each operation is in one of the following formats:

  • ADD P S
  • UPDATE P S
  • QUERY L R

Here, \(P, S, L, R\) are integers.

outputFormat

For every QUERY operation, output the resulting sum on a new line.

## sample
6
ADD 1 10
ADD 2 20
QUERY 1 2
UPDATE 2 15
ADD 3 30
QUERY 2 3
30

45

</p>