Given an array of
nintegers, you are asked to answer
qqueries. Each query is of the form “What is the smallest number that is larger than
xin the given list?”.
The first line of the input contains two integers
n(2 ≤ n ≤ ) and
q(1 ≤ q ≤ ).
The next line contains
nspace-separated integers ( ≤ ≤ ) in an increasing order.
The final line contains
qspace-separated queries ( ≤ < ).
The program should print
qlines. Each line should contain the answer for the corresponding query.
6 3 2 7 9 10 20 30 8 20 1
9 30 2
In the classical implementation of the binary search, we consider the range
lis inclusive and
ris not. In some cases, you might want to have
(l; r]instead - exclude
r. This will require some changes in calculating the
Time limit: 1 seconds
Memory limit: 512 MB
Output limit: 1 MB