#K68977. Taco Query Processor
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 indexx
in the array toy
. - 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:
- The first line contains an integer
N
(\(1 \leq N \leq 10^5\)) representing the size of the array. - The second line contains
N
space-separated integers representing the initial elements of the array \(A\). - The third line contains an integer
Q
(\(1 \leq Q \leq 10^5\)), the number of queries. - 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 indexl
tor
(inclusive).
outputFormat
For every query of type 2
, output the computed sum on a separate line to stdout.
5
1 2 3 4 5
4
2 0 2
1 1 10
2 1 3
2 1 4
6
17
22
</p>