#SGM0000001. Truy vấn tổng đoạn động (Dynamic Range Sum Queries)
Truy vấn tổng đoạn động (Dynamic Range Sum Queries)
Dynamic Range Sum Queries
Source: CSES
Version: Phuoc Hung OJ Extended
Problem Statement
You are given an array of integers and operations. Each operation either assigns a new value to one position or asks for the sum on a contiguous range.
Input
- The first line contains two integers and .
- The second line contains integers .
- Each of the next lines is either
1 k u, which sets , or2 a b, which asks for .
Output
For every operation of type 2, print the requested range sum on its own line.
Subtasks
- Subtask 1 — 20%: , .
- Subtask 2 — 30%: , .
- Subtask 3 — 50%: , .
Examples
Input
8 4
3 2 4 5 1 1 5 3
2 1 4
2 5 6
1 3 1
2 1 4
Output
14
2
11
Explanation
Initially, the sum on is , and the sum on is . After 1 3 1, the third value changes from to , so the new sum on is .