시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
1 초 | 128 MB | 117 | 75 | 57 | 68.675% |
Given a list L containing n integers, find the Range Sum Query (RSQ) between index i and j, inclusive, i.e. RSQ(i, j) = L[i] + L[i+1] + L[i+2] + ... + L[j].
The input starts with an integer t in the first line that denotes the number of test cases in this problem (1 ≤ t ≤ 5).
Each test case starts with a blank line, followed by a line that contains 2 integers: n and q (1 ≤ n, q ≤ 100,000).
Then, the next line contains n non-negative integers up to 1,000,000,000.
Then q lines follow.
Each line contains two integers, i and j (0 ≤ i, j < 10,000).
For each query, print a line containing the value of RSQ(i, j). Separate two test cases with a blank line.
2 5 2 1 2 3 4 5 4 4 1 3 10 5 10 9 7 20 14 23 14 27 38 77 8 9 7 9 6 9 5 9 4 9
5 9 115 142 156 179 193