38 lines
619 B
Python
38 lines
619 B
Python
|
#!/usr/bin/env python3
|
||
|
|
||
|
import sys
|
||
|
|
||
|
def UFM(A):
|
||
|
if len(A) == 0:
|
||
|
return None
|
||
|
|
||
|
m = 0
|
||
|
M = len(A)
|
||
|
|
||
|
while M - 1 != m:
|
||
|
if M - 2 == m:
|
||
|
if A[m] > A[m + 1]:
|
||
|
return A[m]
|
||
|
else:
|
||
|
return A[m + 1]
|
||
|
|
||
|
lh = (M - m) // 2
|
||
|
|
||
|
if A[lh - 1] < A[lh] and A[lh] > A[lh + 1]:
|
||
|
return A[lh]
|
||
|
elif A[lh - 1] < A[lh]:
|
||
|
m = lh
|
||
|
else:
|
||
|
M = lh
|
||
|
|
||
|
return A[m]
|
||
|
|
||
|
A = []
|
||
|
for line in sys.stdin:
|
||
|
line = line.strip()
|
||
|
if line == '' or line == '\n':
|
||
|
break
|
||
|
A.append(int(line))
|
||
|
|
||
|
print(UFM(A))
|