#C4741. Query Delivery Times
Query Delivery Times
Query Delivery Times
You are given an array \(T\) of \(n\) integers, where \(T[i]\) represents the delivery time for the \(i^{th}\) house. You will also be given \(q\) queries. Each query consists of two integers \(l\) and \(r\) (0-indexed), and your task is to compute the total delivery time for houses in the index range \([l, r]\) (inclusive).
Input Format: The first line contains an integer \(n\). The second line contains \(n\) space-separated integers representing the delivery times. The third line contains an integer \(q\), the number of queries. Each of the following \(q\) lines contains two space-separated integers \(l\) and \(r\).
Output Format: For each query, output the sum of the delivery times in the specified range on a new line.
Example:
Input: 6 5 3 8 6 2 7 3 0 2 1 4 3 5</p>Output: 16 19 15
inputFormat
The first line contains an integer \(n\) (the number of houses). The second line contains \(n\) space-separated integers, where the \(i^{th}\) integer represents the delivery time at house \(i\). The third line contains an integer \(q\) (the number of queries). The next \(q\) lines each contain two integers \(l\) and \(r\) (0-indexed), representing a query for the sum of delivery times between indices \(l\) and \(r\) inclusive.
outputFormat
For each query, print the total delivery time for houses in the range \([l, r]\) on a separate line.
## sample6
5 3 8 6 2 7
3
0 2
1 4
3 5
16
19
15
</p>