All submissions for this problem are available.
Semusa won auspicious laureates and was invited for his unique cryptosystem and was invited at a ceremonial event where the host came prepared with a rapid fire round.The rapid fire round was unique just like Semusa’s cryptosystem. Semusa was given a set of numbers and then two types of queries were fired to test Semusa’s out of league IQ.
Semusa is not naive and knows how to get his work done, by programmers like you.
- The first line of the input contains an integer T denoting the number of test cases. The description of T test cases follows.
- The first line of each test case contains two integer N and C denoting the number of elements in array (initially all elements are 0) and number of queries respectively. The following C line contains queries of two types:
1 p q v - You have to add 'v' to all numbers in the given N numbers in the range p to q (both inclusive) where p and q are indices of the array
2 p q - Output a line containing a single integer which is the sum of all the array elements between p and q (both inclusive) where p and q are indices of the array
- 1 ≤ T ≤ 10
- 1 ≤ N ≤ 105
- 1 ≤ C ≤ 105
- 1 ≤ p, q, v ≤ 105
Input: 1 5 3 1 2 3 1 1 3 5 3 2 2 4 Output: 8
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, JAVA, PYP3|
Fetching successful submissions
If you are still having problems, see a sample solution here.