3334: 【模板】二分查找左端点

Memory Limit:128 MB Time Limit:1.000 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

**注意:不建议使用 `std::lower_bound()` 或 `std::upper_bound()` 等函数。** 给定一个长为 $n$ 的数列 $\{a_n\}$,保证数列非严格单调递增,即 $a_i\leqslant a_{i+1}(1\le i

Input

输入共 $m+2$ 行。 第一行两个正整数 $n,m$,代表数列长度和询问次数。 接下来一行 $n$ 个正整数,表示非严格单调递增的数列 $\{a_n\}$。 接下来 $m$ 行,每行一个正整数 $u$,输出它的第一次出现的位置。

Output

输出共 $m$ 行,表示每次询问的答案。

Sample Input Copy

5 3
1 2 2 5 5
1
3
5

Sample Output Copy

1
-1
4