#C11135. Total Travel Distance
Total Travel Distance
Total Travel Distance
You are given the positions of n houses (sorted in non-decreasing order) and q delivery queries. Each query is represented by two integers \(l\) and \(r\) (with \(l \le r\)) which denote the start and end of a delivery segment. The task is to compute the total travel distance for each query, where the travel distance is defined as \(r - l\).
Note: The list of house positions is provided for context, but the travel distance is simply the difference between \(r\) and \(l\).
Input Format: The input is read from standard input.
Output Format: For each query, output the computed travel distance on a new line.
inputFormat
The input is provided via standard input (stdin) and has the following format:
- The first line contains two integers \(n\) and \(q\), where \(n\) is the number of houses and \(q\) is the number of queries.
- The second line contains \(n\) integers representing the positions of the houses (in non-decreasing order).
- The next \(q\) lines each contain two integers \(l\) and \(r\) representing a delivery query.
outputFormat
For each query, output a single integer on a new line representing the total travel distance computed as \(r - l\).
## sample5 3
1 3 6 8 10
1 4
3 9
4 10
3
6
6
</p>