#C4853. Workshop Interest Operations

    ID: 48437 Type: Default 1000ms 256MiB

Workshop Interest Operations

Workshop Interest Operations

You are given \( N \) participants each with an initial interest level. Your task is to process a series of operations to manage and query these interest levels. There are two types of operations:

  • QUERY X Y: Calculate the sum \( \sum_{i=X}^{Y} a_i \) of interest levels from the \( X \)-th participant to the \( Y \)-th participant (1-indexed).
  • UPDATE X V: Change the interest level of the \( X \)-th participant to \( V \).

Output the result for each QUERY operation on a new line.

inputFormat

The input is given from standard input (stdin) in the following format:

N
A1 A2 ... AN
Q
op1
op2
...
opQ

Where:

  • N is the number of participants.
  • The next line contains \( N \) integers representing the initial interest levels \( Ai \).
  • Q is the number of operations.
  • Each of the next \( Q \) lines is either in the format QUERY X Y or UPDATE X V.

outputFormat

For every QUERY operation, output the computed sum on its own line to standard output (stdout).

## sample
5
3 1 4 1 5
3
QUERY 1 3
UPDATE 2 6
QUERY 2 5
8

16

</p>