#C1016. Reverse Subarray Sum
Reverse Subarray Sum
Reverse Subarray Sum
You are given an array of integers and a series of queries. Each query contains two indices, (L) and (R) (0-indexed). For each query, you need to reverse the subarray from index (L) to (R) (both inclusive) and then compute the sum of the elements in this reversed subarray.
Although reversing the subarray does not change its sum, you must perform the reversal operation as described. This problem tests your ability to manipulate subarrays and process multiple queries efficiently.
inputFormat
The input is read from standard input (stdin) with the following format:
1. The first line contains two integers (n) and (q), representing the number of elements in the array and the number of queries, respectively.
2. The second line contains (n) space-separated integers representing the array.
3. Each of the next (q) lines contains two integers (L) and (R) (0-indexed) representing a query.
outputFormat
For each query, output a single line containing the sum of the subarray (after it has been reversed). The output is written to standard output (stdout).## sample
5 3
1 2 3 4 5
1 3
0 4
2 2
9
15
3
</p>