#C10624. Inventory Operations

    ID: 39850 Type: Default 1000ms 256MiB

Inventory Operations

Inventory Operations

You are given an inventory of N products and a series of M operations. Each product has an initial quantity specified in the inventory list. There are two types of operations:

  • Update (U i v): Set the quantity of the product with index \(i\) to \(v\).
  • Query (Q l r): Calculate the sum of quantities of the products with indices from \(l\) to \(r\) (inclusive).

Your task is to process all operations in the given order and output the result for each query operation. Note that the indices are 0-based.

Example:

Input:
5 6
10 20 30 40 50
Q 1 3
U 2 25
Q 2 4
U 4 10
Q 0 4
Q 3 4

Output: 90 115 105 50

</p>

inputFormat

The first line contains two integers \(N\) and \(M\) separated by a space, representing the number of products and the number of operations respectively.

The second line contains \(N\) integers separated by spaces, representing the initial inventory quantities.

The following \(M\) lines each describe an operation in one of the following formats:

  • Q l r for a query operation, where \(l\) and \(r\) are the starting and ending indices of the query range.
  • U i v for an update operation, where \(i\) is the index of the product to be updated and \(v\) is the new quantity.

Indices are 0-based.

outputFormat

For each query operation, output a single line containing the sum of quantities in the specified range.

## sample
5 6
10 20 30 40 50
Q 1 3
U 2 25
Q 2 4
U 4 10
Q 0 4
Q 3 4
90

115 105 50

</p>