Inaho is a scientist. He discovered the fourth dimension recently. In fact, he also discovered the fifth, the sixth, the seventh, the eighth, the ninth, and the tenth dimension! Today, as he was travelling on the infinite plane of uniform density, he fell into an -dimensional hole. "How did that even happen?" he asks himself in disbelief, but quickly realizing that finding his way out is perhaps more important. However, as a measly -dimensional being, he cannot understand the complexities of dimensions.
Fortunately, he knows the way out is the direction with the least density. However, the densities are constantly changing, so he needs to react quickly. Inaho does not know the initial densities, but in a desperate attempt to escape, he assumes them to be .
He will tell you statements, which will either ask you for the sum of the density in a range, or tell you that the density of a certain position changes to . Please help him!
Input Specification
The first line will contain two space-separated integers , and , the number of dimensions and the number of statements respectively.
The second line will contain space-separated integers that represent the size of each dimension, .
The next lines will contain one of the following statements:
- , which represents a change at position to .
- , which represents summing the total density between and inclusive.
Subtasks
For 2 of the 25 available marks, .
For an additional 2 of the 25 available marks, .
For an additional 2 of the 25 available marks, .
For an additional 2 of the 25 available marks, .
NOTE: This problem is practically impossible to solve with Python (even with PyPy). To allow a correct Python solution to pass would require a time limit of 30 seconds, which is unrealistic. It is recommended to use C++.
Output Specification
For each summation statement, output the answer on a separate line.
Sample Input 1
2 7
5 5
1 1 1 2
2 1 1 1 1
1 2 4 12
1 1 1 3
1 5 5 6
2 1 1 4 4
2 2 3 5 5
Sample Output 1
2
15
18
Sample Input 2
10 9
3 3 3 3 3 3 3 3 3 5
1 1 1 1 1 1 1 1 1 2 1 13
1 3 3 3 3 3 3 3 3 3 5 19
1 1 1 3 2 2 2 2 2 2 2 3
2 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2
1 1 1 1 1 1 1 1 1 1 1 24
2 1 1 1 1 1 1 1 1 2 1 3 3 3 3 3 3 3 3 3 5
2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 5
1 1 1 1 1 1 1 1 1 2 1 12
2 1 1 1 1 1 1 1 1 1 1 3 3 3 3 3 3 3 3 3 3
Sample Output 2
13
35
19
39
Comments