#SGM0000046. Truy vấn đa thức (Polynomial Queries)
Truy vấn đa thức (Polynomial Queries)
Polynomial Queries
Source: CSES
Version: Phuoc Hung OJ Extended
Problem Statement
Maintain an array. Query 1 a b adds to consecutive positions . Query 2 a b asks for the range sum.
Input
The first line contains . The second line contains . Each of the next lines is 1 a b (add to consecutive positions) or 2 a b (query the range sum).
Output
For each type-2 query, print the range sum.
Subtasks
-
Subtask 1 (20%): size and operation count at most 30; all other validity conditions are unchanged.
-
Subtask 2 (30%): size and operation count at most 3000; all other validity conditions are unchanged.
-
Subtask 3 (50%): full constraints:
-
-
-
Examples
Input
5 3
4 2 3 1 7
2 1 5
1 1 5
2 1 5
Output
17
32
Explanation
The initial sum is 17. After 1 1 5, the array becomes [5,4,6,5,12], whose sum is 32.