#K68977. Taco Query Processor

    ID: 32984 Type: Default 1000ms 256MiB

Taco Query Processor

Taco Query Processor

You are given an array of N integers and a series of Q queries. There are two types of queries:

  • Update: Query of the form 1 x y means update the element at index x in the array to y.
  • Sum: Query of the form 2 l r means compute the summation \(\sum_{i=l}^{r}A[i]\) and output this value.

Process the queries in the order they appear. For every sum query, output the result on a new line.

Note: Array indices are 0-based.

inputFormat

The input is read from stdin in the following format:

  1. The first line contains an integer N (\(1 \leq N \leq 10^5\)) representing the size of the array.
  2. The second line contains N space-separated integers representing the initial elements of the array \(A\).
  3. The third line contains an integer Q (\(1 \leq Q \leq 10^5\)), the number of queries.
  4. The following Q lines each contain three integers. Each line is either:
    • 1 x y: Update query to set \(A[x]=y\).
    • 2 l r: Sum query to compute and output the sum of the subarray from index l to r (inclusive).

outputFormat

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

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

17 22

</p>