178. Count Elements ≤ X
EasyBinary SearchSorting
For each query x, print how many array elements are ≤ x.
Input format
Line 1: n Line 2: n integers (unsorted) Line 3: q Line 4: q queries
Output format
q answers.
Example 1
Input
5 5 1 3 3 9 3 3 0 10
Output
3 0 5
Example 2
Input
16 14 1 19 26 17 23 8 23 16 1 26 4 11 18 19 16 8 13 16 20 30 23 4 10 6
Output
5 8 12 16 14 3 4 3
Constraints
1 ≤ n, q ≤ 10⁵
Read input from standard input and print the answer to standard output. Your code is judged against 4 test cases, most of them hidden.
Loading the MyLoginn IDE…