#C415. Array Query Processor

    ID: 47656 Type: Default 1000ms 256MiB

Array Query Processor

Array Query Processor

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

  • 1 x y: Update the element at index \(x\) (0-indexed) to \(y\).
  • 2 l r: Compute and output the sum of the subarray from index \(l\) to \(r\) (inclusive).

Your task is to process all the queries in the given order. For every query of the second type, print the resulting sum on a new line.

Note: The queries follow 0-indexing.

inputFormat

The input is given via standard input (stdin) and has the following structure:

  1. An integer \(n\) representing the number of elements in the array.
  2. A line with \(n\) space‐separated integers representing the initial state of the array.
  3. An integer \(q\) representing the number of queries.
  4. \(q\) lines each representing a query in one of the following forms:
    • 1 x y: Update the array at index \(x\) to \(y\).
    • 2 l r: Output the sum of the subarray from index \(l\) to \(r\) inclusive.

outputFormat

For each query of type 2, output the computed sum on a separate line to standard output (stdout).

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

16 22

</p>