~/algor $ cat problems/qidiruv-sonni-topish
Search in a sorted array
Easy
1000 ms
128 MB
20%
$n$ integers sorted in non-decreasing order, $a_{1} \le a_{2} \le \dots \le a_{n}$, and $q$ queries are given. Each query gives an integer $x$: is $x$ in the array?
Input
The first line contains two positive integers: $n$ and $q$. The second line contains $n$ integers $a_{i}$ separated by spaces. Each of the next $q$ lines contains one integer $x$.
Output
$q$ lines: for each query YES ($x$ is in the array) or NO (it is not).
Note
$1 \le n, q \le 10^{5}$
$-10^{9} \le a_{i}, x \le 10^{9}$
$a_{1} \le a_{2} \le \dots \le a_{n}$
Examples
Input #1
5 3 1 3 5 7 9 3 4 9
Output #1
YES NO YES
Input #2
1 2 10 10 -10
Output #2
YES NO