#C1733. Taco Queries
Taco Queries
Taco Queries
You are given a 0-indexed integer array \(A\) of size \(N\) and \(T\) queries. There are two types of queries:
1 X
: Add the integer \(X\) to every element in \(A\).2 L R
: Compute the sum of the subarray from index \(L\) to \(R\) (inclusive), taking into account all previous additions.
Mathematically, for a query of type 2, you must output:
\(\sum_{i=L}^{R} (A_i + c)\), where \(c\) is the cumulative addition from all type 1 queries executed so far.
Process the queries sequentially and output the result for each type 2 query on a new line.
inputFormat
The input is given via standard input (stdin) in the following format:
- The first line contains two integers \(N\) and \(T\) separated by a space.
- The second line contains \(N\) space-separated integers representing the array \(A\).
- The next \(T\) lines each contain a query in one of the following formats: "1 X" or "2 L R".
outputFormat
For each query of type 2, output the corresponding sum on a separate line to standard output (stdout).
## sample5 5
1 2 3 4 5
1 5
2 0 2
2 1 3
1 -2
2 2 4
21
24
21
</p>