logo AlgoBeat OnlineJudge
登录 注册

#202252. [USACO16DEC] Counting Haybales S

内存限制:125 MiB 时间限制:1000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

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.

样例

样例输入 1

4 6
3 2 7 5
2 3
2 4
2 5
2 7
4 6
8 10

样例输出 1

2
2
3
4
1
0