#K47407. Enhance Park Lighting
Enhance Park Lighting
Enhance Park Lighting
You are given an array representing the brightness levels of park lights. You need to perform q operations on this array. There are two types of operations:
- 1 x y: Increase the brightness of the x-th light by y. (Update operation)
- 2 l r: Query the total brightness from the l-th to the r-th light (inclusive). (Query operation)
The query is defined mathematically as: \( \sum_{i=l}^{r} a_i \), where \( a_i \) is the brightness of the i-th light.
Process all operations in the given order and output the result of each query on a new line.
inputFormat
The first line contains two integers n and q, representing the number of park lights and the number of operations respectively. The second line contains n space-separated integers denoting the initial brightness levels. Each of the following q lines contains an operation in one of the following formats:
1 x y
2 l r
For a type 1 operation, increase the brightness of the x-th light by y. For a type 2 operation, output the sum of brightness levels from the l-th to r-th light.
outputFormat
For each query (operation type 2), output the computed brightness sum on a new line.## sample
5 4
1 2 3 4 5
1 3 2
2 1 3
1 5 1
2 4 5
8
10
</p>