#SRD0000006. Cộng đoạn và truy vấn phần tử (Range Update Queries)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Cộng đoạn và truy vấn phần tử (Range Update Queries)
Range Update Queries
Source: CSES
Version: Phuoc Hung OJ Extended
Problem Statement
Start with an array of integers and process operations in their given order. Type 1 a b u adds to every array entry in the inclusive interval . Type 2 k asks for the current value at position . All additions accumulate, including overlapping updates.
Input
The first line contains and the second line the initial array. Each of the following lines is 1 a b u (add on an inclusive range) or 2 k (query the current value at index ).
Output
For each query requesting a result, output one integer on its own line in input order. Update operations produce no output.
Subtasks
- Subtask 1 (15 points): ; ; , , and for all relevant input values.
- Subtask 2 (20 points): ; ; , , and for all relevant input values.
- Subtask 3 (25 points): ; ; , , and for all relevant input values.
- Subtask 4 (40 points): ; ; , , and for all relevant input values.
Examples
Input
8 3
3 2 4 5 1 1 5 3
2 4
1 2 5 1
2 4
Output
5
6
Explanation
Initially . Adding at every position from through changes to . Thus the two outputs are and .