Searching an Array
View as PDFYour friend has a sorted array of  integers, and he wants you to find whether it contains a number 
. You can make a maximum of 
 queries of the following form:
- What is the number at the 
-th position? (1 indexed).
 
Interaction
The first line of input contains two integers,  and 
.
To query the number at the -th position, print a line containing only 
 and the judge will respond with the number 
 at that position, which you can read as a line of input.
To give a final answer, print "YES" or "NO", answering whether the integer exists in the array.
Comments