#C8225. Taco: Array Query Processor

    ID: 52184 Type: Default 1000ms 256MiB

Taco: Array Query Processor

Taco: Array Query Processor

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

  • Type 1: Update query. The query is provided as three integers 1 i v, which means update the element at position i (1-indexed) to the value v.
  • Type 2: Sum query. The query is provided as three integers 2 l r, which means compute the sum of the elements from position l to r (inclusive).

Your task is to process all the queries. For every query of type 2, you should print the computed sum, each on a new line.

The operations are performed in the order the queries appear. Please note that the positions in the array are 1-indexed.

The mathematical summation for a sum query from l to r is defined as:

\[ S = \sum_{i=l}^{r} a_i \]

inputFormat

The input is provided in the following format via stdin:

  1. The first line contains two space-separated integers n and q, representing the number of array elements and the number of queries.
  2. The second line contains n space-separated integers, the elements of the array.
  3. Each of the next q lines contains a query in one of the following formats:
    • For an update query: 1 i v
    • For a sum query: 2 l r

outputFormat

For each query of type 2, output the computed sum on a separate line via stdout.

## sample
5 5
1 2 3 4 5
2 2 4
1 3 10
2 2 4
1 5 -5
2 1 5
9

16 12

</p>