403881: GYM101350 L All’s Wall That Ends Wall

Memory Limit:256 MB Time Limit:3 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

L. All’s Wall That Ends Walltime limit per test3 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard output

In the magical forest, you come upon N walls that you think is a great place to store water for your animal friends. The ith wall consists of ai blocks stacked on top of each other.

Your job is to answer queries of two types:

- For queries of the first type, print the amount of water that could be stored between all the walls.

- For queries of the second type, increase the number of blocks on the xth wall by v.

Input

The first line of input is T – the number of test cases.

The first line of each test case is integers N and Q (1 ≤ N, Q ≤ 105).

The second line contains N space-separated integers ai (1 ≤ ai ≤ 105).

The next Q lines contain either ‘P’ – denoting a query of the first type, or ‘U’ followed by x and v – denoting a query of the second type (1 ≤ x ≤ N) (1 ≤ v ≤ 104).

Output

For each test case and query of the first type, output on a line the amount of water that could be stored between the walls.

ExampleInput
1
6 3
2 1 4 2 1 3
P
U 1 2
P
Output
4
6

加入题单

上一题 下一题 算法标签: