#K35892. Taco Block Queries
Taco Block Queries
Taco Block Queries
Zara has an array of integers and loves to play with blocks of elements. In this problem, you are given an array A of length N and Q queries. Each query is one of the following types:
1 index value
: Update the element at the given index to value.2 L R
: Output the sum of the subarray from index L to R (inclusive). The sum is defined as $$\sum_{i = L}^{R} A_i$$.
You need to process the queries in the order given and for each query of type 2, print the result on a new line.
inputFormat
The first line of input contains two integers N
and Q
, where N
is the number of elements in the array and Q
is the number of queries.
The second line contains N
space-separated integers representing the array A
.
The next Q
lines each contain a query in one of the following formats:
1 index value
— update the array at positionindex
tovalue
.2 L R
— output the sum of the elements from indexL
toR
(inclusive).
Note: Array indices are 0-based.
outputFormat
For each query of type 2
, output the sum of the subarray on a new line.
5 3
1 2 3 4 5
2 1 3
1 2 6
2 1 3
9
12
</p>