Submit solution
Points:
1
Time limit:
4.0s
C++11
0.5s
C++14
0.5s
C++17
0.5s
C++20
0.5s
Memory limit:
256M
Author:
Problem type
Problem Statement
You are given an array of integers. You are also given queries of the following forms:
- Type 1: - update the values of to become
- Type 2: - determine the sum of the range to , i.e.
Input Statement
Your first line will contain two space-separated integers and . Your next line will contain space-separated integers representing . Your next lines will contain two space-separated integers each representing the queries described.
Output Statement
For each type 2 query you should output a new line containing the sum of the range described.
Constraints
- queries are -indexed
- (including after updates)
Sample Cases
Input 1
10 5
1 2 3 4 5 6 7 8 9 10
1 5 -10
2 1 10
1 1 1
2 1 10
2 5 6
Output 1
40
40
-4
Explanation 1
After updating to become -10
, the array is 1 2 3 4 -10 6 7 8 9 10
The sum from 1
to 10
is 40
.
Nothing happens when updating to 1
.
The sum from 1
to 10
is still 40
.
The sum from 5
to 6
is -10 + 6 = -4
.
Comments