Range Updates
View as PDF
Submit solution
Points:
100
Time limit:
1.0s
PyPy 3
3.0s
Python 3
3.0s
Memory limit:
500M
Problem type
You are given an array of integers and must process
queries of the following types:
- Increase every value in the range
by
.
- Report the value at position
.
Positions are 1-indexed.
Input
The first line contains the integer .
The second line contains integers
: the initial values of the array.
The third line contains the integer .
Each of the next lines describes a query and is one of the following:
1 l r u: addto every value in the range
2 k: query the value at position
Output
For each query of type 2, output a line containing the value at position .
Constraints
Example 1
Input
5
8 8 6 7 9
10
1 1 4 3
1 4 5 9
1 1 4 1
2 4
2 3
2 3
2 2
1 1 2 9
1 4 5 1
2 5
Output
20
10
10
12
19
Hints
Hint 1
Try converting this from a range-update / point-query problem into a point-update / range-query problem.
Comments