Problem1537--segment tree exercise

1537: segment tree exercise

Time Limit: 2 Sec  Memory Limit: 128 MB
Submit: 30  Solved: 19
[Submit] [Status] [Web Board] [Creator:]

Description

给出长度为n的数组a_1,a_2,...,a_n,处理q个操作,每个操作为2种类型之一:
1 \ x\ val,把a_x修改为val
2 \ l\ r,输出a_l+a_{l+1}+...+a_r

Input

第一行两个整数n,q(1\le n,q\le 3*10^5)
第二行n个整数a_1,a_2,...,a_n(1\le a_i\le 10^9)
接下来q行每行一个查询。
保证1\le l\le r\le n

Output

对于每个输出操作,输出对应的结果,占一行。

Sample Input

5 5
1 2 3 4 5
2 1 2
2 1 5
1 3 8
2 1 2
2 1 5

Sample Output

3
15
3
20

Source/Category