#abc371d. D - 1D Country
D - 1D Country
Score : points
问题陈述
在数轴上有 个村庄。第 个村庄位于坐标 ,并且有 个村民。
回答 个查询。第 个查询的格式如下:
- 给定整数 和 ,找出位于坐标 和 之间(包括 和 )的村庄中居住的村民总数。
以上为大语言模型 kimi 翻译,仅供参考。
Problem Statement
There are villages on a number line. The -th village is located at coordinate , and has villagers.
Answer queries. The -th query is in the following format:
- Given integers and , find the total number of villagers living in villages located between coordinates and , inclusive.
Constraints
- All input values are integers.
Input
The input is given from Standard Input in the following format:
Output
Print lines.
The -th line should contain the answer to the -th query.
Sample Input 1
4
1 3 5 7
1 2 3 4
4
1 1
2 6
0 10
2 2
Sample Output 1
1
5
10
0
Consider the first query. The villages between coordinates and are the village at coordinate , with villager. Hence, the answer is .
Consider the second query. The villages between coordinates and are the villages at coordinates and , with and villagers, respectively. Hence, the answer is .
Sample Input 2
7
-10 -5 -3 -1 0 1 4
2 5 6 5 2 1 7
8
-7 7
-1 5
-10 -4
-8 10
-5 0
-10 5
-8 7
-8 -3
Sample Output 2
26
15
7
26
18
28
26
11