#SGM0000066. Truy vấn khoảng giá trị (Range Interval Queries)
Truy vấn khoảng giá trị (Range Interval Queries)
Range Interval Queries
Source: CSES
Version: Phuoc Hung OJ Extended
Problem
Given an array , each query gives . Count indices such that and .
Input
The first line contains , the second line contains the array, and each of the next lines contains .
Output
Print the answer for every query.
Subtasks
Subtask 1 (20%)
- , number of queries .
- All other conditions are the same as Subtask 3.
Subtask 2 (30%)
- , number of queries .
- All other conditions are the same as Subtask 3.
Subtask 3 (50%)
Example
Input
8 4
3 2 4 5 1 1 5 3
2 4 2 4
5 6 2 9
1 8 1 5
3 3 4 4
Output
2
0
8
1
Explanation
For the first query the values at positions are [2,4,5]; exactly 2 and 4 lie in .