#C9191. LehaArray Operations
LehaArray Operations
LehaArray Operations
In this problem, you are given an initial array of integers and a series of queries. There are two types of queries:
Update Query: Format 1 i v
— set the ith element (1-indexed) of the array to the value v.
Range Sum Query: Format 2 i j
— compute the sum (\sum_{k=i}^{j} a_k) of the elements from index i to j (1-indexed).
Process the queries in the given order. For each range sum query, output the result on a new line.
inputFormat
The first line contains two integers (n) and (m), representing the number of elements in the array and the number of queries, respectively.\n\nThe second line contains (n) integers which represent the elements of the array.\n\nEach of the following (m) lines contains a query in one of the following formats:
• For an update query: 1 i v
• For a range sum query: 2 i j
outputFormat
For each range sum query (query type 2), output the computed sum on a new line in the order the queries appear.## sample
5 3
1 2 3 4 5
2 2 4
1 3 10
2 2 4
9
16
</p>