#C4159. Sequence Query Processing
Sequence Query Processing
Sequence Query Processing
You are given a sequence of N integers. Your task is to process Q queries on this sequence. There are three types of queries:
- Type 1 (Assignment): Set every element of the sequence to a given value x. Mathematically, the new sum of the sequence becomes $$x \times N$$.
- Type 2 (Increment): Add a given value x to every element of the sequence. This increases the total sum by $$x \times N$$.
- Type 3 (Query): Output the current sum of the sequence.
You need to process the queries in the order given and output the result for every type 3 query.
inputFormat
The input is read from standard input and has the following format:
N Q A1 A2 ... AN query1 query2 ... queryQ
Where:
- The first line contains two integers: N (the length of the sequence) and Q (the number of queries).
- The second line contains N space-separated integers representing the initial sequence.
- Each of the next Q lines contains two integers t and x, representing a query. For type 3 queries, the value x can be ignored.
outputFormat
For each query of type 3, output the current sum of the sequence on a new line. The output should be written to standard output.
## sample5 6
1 2 3 4 5
1 10
3 0
2 5
3 0
1 -5
3 0
50
75
-25
</p>