#P9802. Easy problem II
Easy problem II
Easy problem II
Problem Description
note:The difference is that in this version,operation is different,, can take any possible value. For a given sequence of intergers . There are two types of operations: — for each ,change $a_i = \begin{cases} x - a_i &\text{if } a_i < x \\\\ x + a_i &\text{if } a_i \geq x \end{cases}$. — output
Input
The input consists of multiple test cases. The first line contains a single integer — the number of test cases. The first line of each test case contains two integers and — the length of sequence and the number of operations. The next line contains integer The next line contains some integers $(1 \leq \text{opt} \leq 2,1 \leq l \leq r \leq n,0 \leq x \leq 10^7)$ — indicating the operations.
Output
For each query, output an interger in a single line indicating the .
Sample Input
1
5 5
1 2 3 4 5
1 1 5 3
2 1 2
2 2 4
1 2 3 5
2 1 5
Sample Output
3
14
32
Source
2023“钉耙编程”中国大学生算法设计超级联赛(1)