#SGM0000065. Truy vấn k (K-query)
Truy vấn k (K-query)
K-query
Source: SPOJ
Version: Phuoc Hung OJ Extended
Problem
You are given an array . Each query contains . Count how many values in are strictly greater than .
Input
The first line contains . The second line contains the array. The third line contains . Each of the next lines contains .
Output
For each query, print the number of values greater than in .
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
5
5 1 2 3 4
3
2 4 1
4 4 4
1 5 2
Output
2
0
3
Explanation
For 2 4 1, the segment is [1,2,3], and two values are greater than .