Time Limit: 1 second(s) | Memory Limit: 64 MB |
Robin Hood likes to loot rich people since he helps the poor people with this money. Instead of keeping all the money together he does another trick. He keeps n sacks where he keeps this money. The sacks are numbered from 0 to n-1.
Now each time he can he can do one of the three tasks.
1) Give all the money of the i^{th} sack to the poor, leaving the sack empty.
2) Add new amount (given in input) in the i^{th} sack.
3) Find the total amount of money from i^{th} sack to j^{th} sack.
Since he is not a programmer, he seeks your help.
Input starts with an integer T (≤ 5), denoting the number of test cases.
Each case contains two integers n (1 ≤ n ≤ 10^{5}) and q (1 ≤ q ≤ 50000). The next line contains n space separated integers in the range [0, 1000]. The i^{th} integer denotes the initial amount of money in the i^{th} sack (0 ≤ i < n).
Each of the next q lines contains a task in one of the following form:
1 i Give all the money of the i^{th} (0 ≤ i < n) sack to the poor.
2 i v Add money v (1 ≤ v ≤ 1000) to the i^{th} (0 ≤ i < n) sack.
3 i j Find the total amount of money from i^{th} sack to j^{th} sack (0 ≤ i ≤ j < n).
For each test case, print the case number first. If the query type is 1, then print the amount of money given to the poor. If the query type is 3, print the total amount from i^{th} to j^{th} sack.
Sample Input |
Output for Sample Input |
1 5 6 3 2 1 4 5 1 4 2 3 4 3 0 3 1 2 3 0 4 1 1 |
Case 1: 5 14 1 13 2 |
Dataset is huge, use faster I/O methods.
Developed and Maintained by
JANE ALAM JAN |
Copyright © 2012
LightOJ, Jane Alam Jan |