COCI '07 Contest 1 #3 Prinova

View as PDF

Submit solution


Points: 7 (partial)
Time limit: 0.6s
Memory limit: 32M

Problem type

Brojko and Brojana are happily married with N little boys. The boys are named with distinct even integers P1,P2,,PN.

Brojko and Brojana are expecting an addition to their family and have to come up with a nice name for the little girl. They have decided that the name will be an odd integer in the range [A,B]. Because they find all integers in that range equally beautiful, they have decided to choose the number which maximizes the distance to the name of the closest of the N boys.

More precisely, they seek an odd integer X[A,B] such that the expression min{|XPi|,i[1,N]} is as large as possible.

Write a program that determines the name for the little girl. If there are multiple solutions, output any of them.

Input Specification

The first line contains an integer N (1N100), the number of boys. The second line contains N distinct even integers, the names of the boys. The integers will be less than 109. The third line contains the integers A and B (1A<B109), the range of names they are considering for the girl.

Output Specification

Output an integer, the name for the little girl.

Sample Input 1

Copy
3
2 6 16
20 50

Sample Output 1

Copy
49

Sample Input 2

Copy
3
2 6 16
3 15

Sample Output 2

Copy
11

Sample Input 3

Copy
3
2 6 16
1 7

Sample Output 3

Copy
5

Comments


  • 11
    dxke02  commented on Nov. 9, 2020, 4:10 p.m.

    What sort of parents name their kids with numbers?