luogu#P3184. [USACO16DEC] Counting Haybales S
[USACO16DEC] Counting Haybales S
题目描述
Farmer John has just arranged his haybales () at various points along the one-dimensional road running across his farm. To make sure they are spaced out appropriately, please help him answer queries (), each asking for the number of haybales within a specific interval along the road.
输入格式
The first line contains and .
The next line contains distinct integers, each in the range , indicating that there is a haybale at each of those locations.
Each of the next lines contains two integers and () giving a query for the number of haybales between and , inclusive.
输出格式
You should write lines of output. For each query, output the number of haybales in its respective interval.
题目大意
题目描述
Farmer John 刚刚将他的 个干草捆()安排在他农场的一维道路上的各个位置。为了确保它们之间的间距合适,请帮助他回答 个查询(),每个查询询问在道路的特定区间内有多少个干草捆。
输入格式
第一行包含 和 。
第二行包含 个不同的整数,每个整数的范围在 之间,表示每个位置上有一个干草捆。
接下来的 行每行包含两个整数 和 (),表示一个查询,询问在 到 (包括 和 )的区间内有多少个干草捆。
输出格式
你需要输出 行。对于每个查询,输出其对应区间内的干草捆数量。
4 6
3 2 7 5
2 3
2 4
2 5
2 7
4 6
8 10
2
2
3
4
1
0