Sum of Query II
Medium Accuracy: 51.12% Submissions: 5557 Points: 4

You are given an array and q queries which contains 2 positions in the array l and r. You need to compute the following sum over q queries.


Array is 1-Indexed

The first line of input contains T test cases. The first line of each test case contains the number of elements in the array.The second line of each test case contains the elements of the array.The third line of each test case contains Q queries.The final line of each test case contains the 2 *Q elements where the first element contains l and second element contains r. 

For each test case, print the required sum values in a single line seprated by blank spaces. Print the output of each test case in a new line.

1 <= T <= 100
1 <= N <= 1000
0 <= Arr[i] <= 106 
1 <= Q <= 1000
1 <= l <= r <= N

1 2 3 4

1 4 2 3 

10 5

to report an issue on this page.


We strongly recommend solving this problem on your own before viewing its editorial. Do you still want to view the editorial?


All Submissions

My Submissions:

Login to access your submissions.