#P7480. Rikka with Sequence
Rikka with Sequence
Rikka with Sequence
Problem Description
As we know, Rikka is poor at math. Yuta is worrying about this situation, so he gives Rikka some math tasks to practice. There is one of them:
Yuta has an array with numbers and he keeps a copy of the initial value of array as . Then he makes operations on it.
There are three types of operations:
Input
The first line contains two numbers . The second line contains n numbers . Then m lines follow, each line describe an operation. It is guaranteed that
Output
For each query, print a single line with a single number -- the answer.
Sample Input
5 7
1 2 3 4 5
1 1 5
2 3 4 1
1 1 5
2 3 4 2
1 1 5
3 1 5
1 1 5
Sample Output
15
12
11
15
Source
2017 Multi-University Training Contest - Team 5