#C7020. Taco Query Processing

    ID: 50846 Type: Default 1000ms 256MiB

Taco Query Processing

Taco Query Processing

You are given an array A of n integers and q queries. There are two types of queries:

  • 1 i x: Update the element at index i to x.
  • 2 l r: Compute the sum of the segment of the array from index l to r (inclusive). Formally, you need to calculate $$\text{sum} = \sum_{i=l}^{r} A_i.$$

For each query of the second type, output the result on a separate line. The array indices are 0-based.

inputFormat

The input is given in the following format:

n q
A[0] A[1] ... A[n-1]
query_1
query_2
... 
query_q

Here, each query is in one of the following formats:

  • 1 i x: Update operation where A[i] becomes x.
  • 2 l r: Sum query where you need to calculate the sum of elements from index l to r (inclusive).

outputFormat

For each query of type 2, output the resulting sum on a separate line.

## sample
5 5
1 2 3 4 5
2 0 4
1 3 10
2 1 3
1 0 6
2 0 2
15

15 11

</p>