logo AlgoBeat OnlineJudge
登录 注册

#213868. [CERC 2021] DJ Darko

内存限制:256 MiB 时间限制:4000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

A new DJ is in town. DJ Darko needs to set up his speakers. He has speakers in a row with the -th speaker volume set to . Changing the volume is rather difficult so the -th speaker requires units of energy to increase or decrease the volume by the value of 1.

Unfortunately, Darko's evil twin brother Karko likes to mess with him. There are events that will be happening.

1 l r x

2 l r

In an event of type 1, Karko changes the volume of all speakers from the -th to the -th by . In an event of type 2, Darko sets all the speakers from the -th to the -th to the same volume in a way that uses up the minimal amount of energy. If there are multiple ways of doing that, he chooses the one which minimizes the final volume.

As a bystander, you would like to know the volume that Darko set for each event of type 2.

输入格式

The first line contains the number of speakers and the number of events . In the second line, there are numbers indicating the current volume of the speakers. In the third line, there are numbers , indicating the energy needed to change the volume of the -th speaker by one. In the next lines there are events, formatted in the way described above. All numbers in the input are integers.

输出格式

For each event of type 2, output the volume to which Darko set the speakers.

样例

样例输入 1

5 5
8 1 6 4 9
3 6 4 1 7
2 2 4
1 1 4 -8
2 1 1
2 1 3
2 4 5

样例输出 1

1
0
-7
9

样例输入 2

8 3
4 3 9 3 7 6 4 8
9 5 8 5 2 2 1 8
1 1 7 -10
2 5 5
2 4 7

样例输出 2

-3
-7

数据范围与提示

Input limits