169. First Position Not Less Than X
EasyBinary Search
For each query x, print the first 0-based index i with a[i] ≥ x in the sorted array, or n if there is none.
Input format
Line 1: n Line 2: n sorted integers Line 3: q Line 4: q queries
Output format
q answers, space-separated.
Example 1
Input
5 1 2 4 4 7 4 4 3 8 0
Output
2 2 5 0
Example 2
Input
1 5 2 5 6
Output
0 1
Constraints
1 ≤ n, q ≤ 10⁵
Read input from standard input and print the answer to standard output. Your code is judged against 5 test cases, most of them hidden.
Loading the MyLoginn IDE…