VMSS Pre-Pre-Windsor P4 - The New Kid
View as PDFJagdeep is moving into a neighbourhood near Massey. Since Jagdeep is such a popular kid, he already knows every single person on the street he is looking to move to. There are  houses that are empty 
, but there are also 
 houses with people in them who he doesn't like 
. Each house is up to 
 meters away from the front of the street, and each house is on the street. What is the position of the empty house that is the farthest away from the 
 houses with people in them who Jagdeep doesn't like?
Input Specification
The first line contains two integers,  and 
, separated by a space. On each of the next 
 lines, there is a single non-negative integer denoting the position of an empty house. On each of the next 
 lines, there is a single non-negative integer denoting the position of a house with people in them who Jagdeep doesn't like.
Output Specification
The position of the empty house that is the farthest away from the  houses with people in them who Jagdeep doesn't like. If there are multiple empty houses that tie for farthest distance, output the one closest to the front of the street.
Sample Input
3 5
3
24
18
2
23
7
14
25
Sample Output
18
Explanation for Sample Output
There are empty houses at , 
, and 
. The first empty house is closest to 
, so its distance is 
. The second empty house is closest to 
 or 
, so its distance is 
. The third empty house is closest to 
, so its distance is 
. The answer is the position of the third empty house, which is 
.
Comments