Implement a binary search algorithm.
Input:
- the first line of the input contains natural numbers N and K (\(0<N,\ K < ;= 100000\));
- the second line contains N elements of the first array, sorted in ascending order;
- on the third line – K elements of the second array.
The elements of both arrays are integers, each of which does not exceed \(10^9\).
Output: required for each of the K numbers to print in a separate line "YES" ; if this number occurs in the first array, and "NO" otherwise.
Examples
| # |
Input |
Output |
| 1 |
105
1 2 3 4 5 6 7 8 9 10
-2 0 4 9 12
|
NO
NO
YES
YES
NO
|