问题 K: Easy problem II

内存限制:512 MB 时间限制:8 S 标准输入输出
题目类型:传统 评测方式:文本比较 上传者:
提交:0 通过:0

题目描述

note:The difference is that in this version,operation 11 is different,�,�≤105n,m≤105, �x can take any possible value.
For a given sequence of �n intergers �a.
There are two types of operations:
1���(1≤�≤�≤�)1lrx(1≤l≤r≤n) — for each �∈[�,�]i∈[l,r] ,change ��={�−��if ��<��+��if ��≥�ai={x−aix+aiif ai<xif ai≥x.
2��(1≤�≤�≤�)2lr(1≤l≤r≤n) — output ans=∑�=����ans=i=l∑rai

输入格式

The input consists of multiple test cases. The first line contains a single integer �(1≤�≤1)T(1T1) — the number of test cases.

The first line of each test case contains two integers n and �,(1≤�≤105,1≤�≤105)m,(1n105,1m105)— the length of sequence and the number of operations.

The next line contains n integer ��(0≤��≤107)ai(0ai107)

The next m line contains some integers opt,�,�,�opt,l,r,x (1≤opt≤2,1≤�≤�≤�,0≤�≤107)(1opt2,1lrn,0x107) — indicating the operations.

输出格式

For each query, output an interger in a single line indicating the ansans.

输入样例 复制

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

输出样例 复制

3
14
32

分类标签