#K47497. Taco Array Operations

    ID: 28211 Type: Default 1000ms 256MiB

Taco Array Operations

Taco Array Operations

You are given an array (A) of (N) integers and (Q) operations. There are two types of operations:

  1. Update operation: Given an index (i) and an integer (x), update (A[i]) to (x). (Note: the index is 1-based.)
  2. Query operation: Given two indices (l) and (r), find the sum [ S = \sum_{i=l}^{r} A[i] ] of the subarray from index (l) to (r).

Your task is to process all (Q) operations in the given order and output the result of every query operation. The input format is from (stdin) and the output format is to (stdout).

inputFormat

The first line contains two space-separated integers (N) and (Q), the size of the array and the number of operations respectively.
The second line contains (N) space-separated integers, the initial elements of the array (A).
Then (Q) lines follow, each representing an operation:\

  • An update operation is given in the format: 1 i x, which means update the element at index (i) to (x). (1-based index)\
  • A query operation is given in the format: 2 l r, which means output the sum of elements from index (l) to (r) (inclusive).

outputFormat

For each query operation, output a single line containing the sum of the specified subarray.## sample

5 4
1 2 3 4 5
2 1 3
1 2 10
2 1 3
2 1 5
6

14 23

</p>