Binary search
Very easy
Execution time limit is 5 seconds
Runtime memory usage limit is 256 megabytes
A sorted array of integers is given. It is necessary to answer queries: whether the given number is present in the array.
Input
The first line contains two integers and . The second line contains integers sorted in ascending order. Each of the following lines contains one number . All numbers in the array do not exceed by absolute value.
Output
For each query, print "YES" on a separate line if the number is present in the array, and "NO" otherwise.
Examples
Input #1
Answer #1
Input #3
Answer #3
Submissions 11K
Acceptance rate 43%