#SGM0000035. Cập nhật đoạn và tổng (Range Updates and Sums)
Cập nhật đoạn và tổng (Range Updates and Sums)
Range Updates and Sums
Source: CSES
Version: Phuoc Hung OJ Extended
Problem Statement
Maintain an array with range addition, range assignment, and range-sum queries.
Input
The first line contains and the next line contains the initial array. Queries are:
1 a b x: add to .2 a b x: assign every element of to .3 a b: calculate the sum of .
Output
Print the answer for every type 3 query.
Subtasks
- 20 points: .
- 30 points: .
- 50 points: , .
Examples
Input
6 5
2 3 1 1 5 3
3 3 5
1 2 4 2
3 3 5
2 2 4 5
3 3 5
Output
7
11
15
Explanation
Initially . Adding 2 to changes that sum to 11. Assigning to 5 makes equal to 5 5 5, so the final answer is 15.