#SGM0000070. Super Mario (Super Mario)
Super Mario (Super Mario)
Super Mario (Super Mario)
Source: HDU
Version: Phuoc Hung OJ Extended
Problem
There are bricks at positions , with height . For each query , count positions in whose height is at most .
Input
The first line contains , the second line contains the heights, and each next line contains .
Output
Print the number of bricks with height at most 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%)
- indexing is 0-based
Example
Input
10 10
0 5 2 7 5 4 3 8 7 7
2 8 6
3 5 0
1 3 1
1 9 4
0 1 0
3 5 5
5 5 1
4 6 3
1 5 7
5 7 3
Output
4
0
0
3
1
2
0
1
5
1
Explanation
For the first query, the heights at positions are [2,7,5,4,3,8,7]; four are at most .