Problem:


Score : 400 points

Problem Statement

Let {\rm comb}(n,r) be the number of ways to choose r objects from among n objects, disregarding order.
From n non-negative integers a_1, a_2, ..., a_n, select two numbers a_i > a_j so that {\rm comb}(a_i,a_j) is maximized.
If there are multiple pairs that maximize the value, any of them is accepted.

Constraints

2 \leq n \leq 10^5

0 \leq a_i \leq 10^9

a_1,a_2,...,a_n are pairwise distinct.

All values in input are integers.

Input

Input is given from Standard Input in the following format:

n
a_1 a_2 ... a_n

Output

Print a_i and a_j that you selected, with a space in between.

Sample Input 1

5
6 9 4 2 11

Sample Output 1

11 6

\rm{comb}(a_i,a_j) for each possible selection is as follows:

\rm{comb}(4,2)=6 

\rm{comb}(6,2)=15 

\rm{comb}(6,4)=15 

\rm{comb}(9,2)=36 

\rm{comb}(9,4)=126 

\rm{comb}(9,6)=84 

\rm{comb}(11,2)=55 

\rm{comb}(11,4)=330 

\rm{comb}(11,6)=462 

\rm{comb}(11,9)=55

Thus, we should print 11 and 6.

Sample Input 2

2
100 0

Sample Output 2

100 0



Sample input:
5
6 9 4 2 11


Sample output:
11 6

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
A.sort()
X = A[-1]
X2 = X // 2
dd = A[-1]
for i in range(N - 1):
    d = abs(X2 - A[i])
    if d < dd:
        Y = A[i]
print(X, Y)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = sorted(list(map(int, input().split())))

ans_n = A.pop()
target = ans_n / 2

ans_r = - 1
high_score = 0
for r in A:
    min_r = min(ans_n - r, r)
    if min_r > high_score:
        high_score = r
        ans_r = r

print(ans_n, ans_r)

Submission status: Wrong Answer

Solution code:
n = int(input())
list_a = list(map(int, input().split()))
m = max(list_a)
search = m/2
min_a = abs(list_a[0] - search)
min_ind = 0
for i in range(n):
    if min_a > abs(list_a[i] - search):
        min_a = abs(list_a[i] - search)
        min_ind = i

print(m, list_a[min_ind])

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int, input().split()))

a_i = max(a)
a2 = sorted(a, key = lambda x: abs(2 * x - a_i))
a_j = a2[0]

print(a_i, a_j)

Submission status: Wrong Answer

Solution code:
import sys
Input = sys.stdin.readline
#Input = input

n = int(Input())
a = list(map(int, Input().split()))

c_n = max(a)
c_r = None
c_r_err = float("inf")
for i in a:
    err = abs((c_n//2) - i)
    if err < c_r_err:
        c_r = i
        c_r_err = err

print("{0} {1}".format(c_n, c_r))

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int,input().split()))

ma = max(a)
ma2 = ma/2
mi = 999999999999.0
mii = -1
for i in a:
    if abs(ma2 - i) < mi and i != ma:
        mi = ma2 - i
        mii = i

print(ma,mii,sep=" ")

Submission status: Wrong Answer

Solution code:
n = int(input())
A = [int(a) for a in input().split()]

A.sort()
if n == 2:
    print(A[0],A[1])
else:
    ans_a = A[n-1]

    left = 0
    right = n-1
    while True:
        if left == right:
            ans_b = A[left]
            break
        elif left + 1 == right:
            if abs(A[left]-ans_a/2) < abs(A[right]-ans_a/2):
                ans_b = A[left]
            else:
                ans_b = A[right]
            break
        elif ans_a//2 < A[(left+right)//2]:
            right = (left+right)//2
        else:
            left = (left+right)//2

    print(ans_a,ans_b)

Submission status: Wrong Answer

Solution code:
n = int(input())
A = [int(a) for a in input().split()]

A.sort()

ans_a = A[n-1]

left = 0
right = n-1
while True:
    if left == right:
        ans_b = A[left]
        break
    elif left + 1 == right:
        if abs(A[left]-ans_a/2) < abs(A[right]-ans_a/2):
            ans_b = A[left]
        else:
            ans_b = A[right]
        break
    elif ans_a//2 < A[(left+right)//2]:
        right = (left+right)//2
    else:
        left = (left+right)//2

print(ans_a,ans_b)

Submission status: Wrong Answer

Solution code:
from bisect import bisect_left as bi
n = int(input())
x = list(map(int, input().split()))
x.sort()
a = x.pop()
k = bi(x, a / 2, 0, len(x))
if k == 0:
    print(str(a) + " " + str(x[k]))
elif k == len(x):
    print(str(a) + " " + str(x[k-1]))
elif abs(a - x[k]) > abs(a - x[k - 1]):
    print(str(a) + " " + str(x[k-1]))
else:
    print(str(a) + " " + str(x[k]))

Submission status: Wrong Answer

Solution code:
n = int(input())
lst = sorted(list(map(int, input().split())))
maxi = lst[-1]
half = maxi / 2
diff = min([abs(elem - half) for elem in lst[:-1]])
if int(diff + half) in lst:
    print(maxi, int(diff + half))
else:
    print(maxi, int(diff - half))

Submission status: Wrong Answer

Solution code:
n = int(input())
A = list(map(int, input().split()))

if len(A) == 2:
    print(A[1], A[0])
else:
    A.sort()

    a = A[-1]

    k = a / 2
    B = [a for a in A if a <  k]
    C = [a for a in A if a >= k]

    if k - B[-1] > C[0] - k:
        print(a, C[0])
    else:
        print(a, B[-1])

Submission status: Wrong Answer

Solution code:
n = int(input())
A = list(map(int, input().split()))

if len(A) == 2:
    print(A[1], A[0])
else:
    A.sort()

    a = A[-1]

    k = a / 2
    B = []
    C = []

    for j in range(n):
        if A[j] < k:
            B.append(A[j])
        else:
            C.append(A[j])
            break

    if k - B[-1] > k - C[0]:
        print(a, C[0])
    else:
        print(a, B[-1])

Submission status: Wrong Answer

Solution code:
n = int(input())
a_list = [i for i in list(map(int, input().split()))]

a_list.sort()
max_num = a_list.pop(-1)
can1 = a_list[len(a_list)//2]
print(str(max_num) + " " + str(can1))

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))

p = max(A)

As = sorted(A)

q = 0

for x in As:
  if p == x:
    break
  elif abs(p/2-x) < abs(p/2-q):
    q = x
  else:
    break
    
print(p,q)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))

p = max(A)

As = sorted(A)

q = 0

for x in As:
  if abs(p/2-x) < abs(p/2-q):
    q = x
  else:
    break
    
print(p,q)

Submission status: Wrong Answer

Solution code:
import bisect

n = int(input())
a = sorted(list(map(int, input().split())))

X = a[-1]

i = bisect.bisect_left(a, X / 2, hi = n - 2)
j = bisect.bisect_right(a, X / 2, hi = n - 2)

if abs(X / 2 - a[i]) < abs(X / 2 - a[j]):
    print(str(X) + ' ' + str(a[i]))
else:
    print(str(X) + ' ' + str(a[j]))

Submission status: Wrong Answer

Solution code:
import bisect

def comb(n, r):
    if r == 0:
        return 1
    else:
        return comb(n-1, r- 1) * n / r

n = int(input())
a = sorted(list(map(int, input().split())))

X = a[-1]
i = bisect.bisect_left(a, X / 2, lo = 0, hi = n - 2)
if i == n - 2:
    ans = [str(X), str(a[i])]
elif abs(a[i] - X / 2) < abs(a[i + 1] - X / 2):
    ans = [str(X), str(a[i])]
else:
    ans = [str(X), str(a[i + 1])]

print(' '.join(ans))

Submission status: Wrong Answer

Solution code:
import bisect

def comb(n, r):
    if r == 0:
        return 1
    else:
        return comb(n-1, r- 1) * n / r

n = int(input())
a = sorted(list(map(int, input().split())))

X = a[-1]
i = bisect.bisect_left(a, X / 2, lo = 0, hi = n - 2)
if abs(a[i] - X / 2) < abs(a[i + 1] - X / 2):
    print(str(X) + ' ' + str(a[i]))
else:
    print(str(X) + ' ' + str(a[i + 1]))

Submission status: Wrong Answer

Solution code:
n = int(input())
A = list(map(int, input().split()))

max_a = max(A)

for i in reversed(range(max_a // 2 + 1)):
    print(i)
    if(i in A):
        print(max_a, i)
        break
    elif((max_a - i) in A):
        print(max_a, max_a - i)
        break

Submission status: Wrong Answer

Solution code:
n = int(input())
A = list(map(int, input().split()))

max_a = max(A)

half = -1 * (-1 * max_a // 2)
for i in reversed(range(half)):
    # print(i)
    if(i in A):
        print(max_a, i)
        break
    elif((max_a - i) in A):
        print(max_a, max_a - i)
        break

Submission status: Wrong Answer

Solution code:
import numpy as np
import math

def nCr(n,r):
    f = math.factorial
    return f(n) / f(r) / f(n-r)

N = int(input())
A = list(map(int, input().split()))


# Choose the largest element
largestA = max(A)
max_n = A.index(largestA)

min_dif = 1000000
min_n = -1
for n in range(N):
    if n == max_n:
        continue
    dif = int(abs(A[n] - int(largestA / 2)))
    if dif < min_dif:
        min_dif = dif
        min_n = n
        # print(min_dif)
        # print(min_n)


# print(nCr(largestA, A[min_n]))
print(largestA, A[min_n])

Submission status: Wrong Answer

Solution code:
_ = input()
 
axs = list(map(int, input().split()))
 
i = max(axs)
j = min(axs, key=lambda j: abs((i/2) - j))
print('{} {}'.format(i, j))

Submission status: Wrong Answer

Solution code:
n = int(input())
A = list(map(int, input().split()))
MA = max(A)
N = MA/2
if A.index(MA) == 0:
    k = A.index(min(A))
else:
    k = 0
X = max(A)-1
for i in range(n):
    if abs(A[i] - N) < X:
        X = abs(A[i] - N)
        k = i       
print('{} {}'.format(MA, A[k]))

Submission status: Wrong Answer

Solution code:
n = int(input())
A = list(map(int, input().split()))
MA = max(A)
N = MA/2
if A.index(MA) == 0:
    k = A.index(min(A))
else:
    k = 0
X = max(A)
for i in range(n):
    if abs(A[i] - N) < X:
        X = abs(A[i] - N)
        k = i       
print('{} {}'.format(MA, A[k]))

Submission status: Wrong Answer

Solution code:
n = int(input())
A = list(map(int, input().split()))
MA = max(A)
N = MA/2
k = 0
X = max(A)
for i in range(n):
    if abs(A[i] - N) < X:
        X = abs(A[i] - N)
        k = i     
print('{} {}'.format(MA, A[k]))

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
a = max(A)
b = a/2
import numpy as np
def getNearestValue(list, num):
    idx = np.abs(np.asarray(list) - num).argmin()
    return list[idx]
c = getNearestValue(A,b)
print(a,c)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
b=max(a)
c=b
d=0
for i in a:
  if c>abs(b/2-i):c=abs(b/2-i);d=i
print(b,d)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
b=max(a)
c=b
d=0
for i in a:
  if c<abs(b/2-i):c=abs(b/2-i);d=i
print(b,d)

Submission status: Wrong Answer

Solution code:
from math import factorial

n = int(input())
a = list(map(int, input().split()))
max_a = max(a)
dis = float('inf')
ans = 0
for a_i in a:
    if abs(a_i - max_a//2) < dis:
        ans = a_i
        dis = abs(a_i - max_a//2)

print(max_a, ans)

Submission status: Wrong Answer

Solution code:
from math import factorial

n = int(input())
a = list(map(int, input().split()))
a.sort()
max_a = max(a)
a.pop()
ans_r, ans_l = 0, 0
comb = 0
for a_i in a:
    if a_i >= max_a//2:
        ans_r = a_i
        break

for a_i in a[::-1]:
    if a_i <= max_a//2:
        ans_l = a_i
        break
if (max_a//2 - ans_l) > (max_a//2 - ans_r):
    ans = ans_r
else:
    ans = ans_l
print(max_a, ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
A =[int(i) for i in input().split()]
a = max(A)
if a%2==0:
    seco=0
    s =a//2
    for i in A:
        if i <=s:
            seco=max(seco,i)
        else:
            seco=max(seco,a-i)
if a%2==1:
    seco=0
    s = a//2 +1
    for i in A:
        if i <=s:
            seco=max(seco,i)
        else:
            seco=max(seco,a-i)
print(a,seco)

Submission status: Wrong Answer

Solution code:
from scipy.misc import comb
import bisect
n = int(input())
a = list(map(int,input().split()))
a.sort()
m = max(a)
b = [0 for i in range(n)]
if n != 2:
	if m%2 == 0:
		target = m//2
		insert_index = bisect.bisect_left(a,target)
		ans = comb(m,a[insert_index])
		r = a[insert_index]
		if insert_index+1 < n and ans < comb(m,a[insert_index+1]):
			ans = comb(m,a[insert_index+1])
			r = a[insert_index+1]
		if insert_index-1 >= 0 and ans < comb(m,a[insert_index-1]):
			ans = comb(m,a[insert_index-1])
			r = a[insert_index-1]
	else:
		target1 = (m+1)//2
		insert_index = bisect.bisect_left(a,target1)
		ans = comb(m,a[insert_index])
		r = a[insert_index]
		if insert_index+1 < n and ans < comb(m,a[insert_index+1]):
			ans = comb(m,a[insert_index+1])
			r = a[insert_index+1]
		if insert_index-1 >= 0 and ans < comb(m,a[insert_index-1]):
			ans = comb(m,a[insert_index-1])
			r = a[insert_index-1]
		
		target2 = (m-1)//2
		insert_index2 = bisect.bisect_left(a,target2)
		if ans < comb(m,a[insert_index2]):
			ans = comb(m,a[insert_index2])
			r = a[insert_index2]
		if insert_index2+1 < n and ans < comb(m,a[insert_index2+1]):
			ans = comb(m,a[insert_index2+1])
			r = a[insert_index2+1]
		if insert_index2-1 >= 0 and ans < comb(m,a[insert_index2-1]):
			ans = comb(m,a[insert_index2-1])
			r = a[insert_index2-1]
	print(m,r)
else:
	print(m,(a[0]+a[1])-m)

Submission status: Wrong Answer

Solution code:
import bisect
import sys
import math

n = int(input())
array = sorted([int(x) for x in input().split()])
if n == 2:
    print(array[1], array[0])
    sys.exit()

half = math.ceil(array[-1]/2)
pos = bisect.bisect_left(array, half)
_dict = {}
_dict[abs(half - array[pos])] = array[pos]
_dict[abs(half - array[pos-1])] = array[pos-1]
_dict[abs(half - array[pos+1])] = array[pos+1]

print(_dict)
res = _dict[min(_dict.keys())]
print(array[-1], res)

Submission status: Wrong Answer

Solution code:
import bisect
import sys

n = int(input())
array = sorted([int(x) for x in input().split()])
if n == 2:
    print(array[1], array[0])
    sys.exit()

half = array[-1]//2
pos = bisect.bisect_left(array, half)
res = array[pos] if (array[-1] - array[pos]) > (array[-1] - array[pos+1]) else array[pos+1]
print(array[-1], res)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=[int(i) for i in input().split()]
m=max(a)
m2=m/2
f=m
ans=-m
for i in a:
  if i != m and abs(m2 - i) <=f:
    f = m2 - i
    ans = i
print(m,ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = set(map(int, input().split()))

if len(a) == 1:
    result = list(a)[0]
    print("{} {}".format(result, result))

x = max(a)
result = min(a)
for i in sorted(a):
    if i == (x // 2):
        break
    elif i < x / 2:
        result = i
    elif (i - x / 2) < (x / 2 - result):
        result = i
        break
    else:
        break

print("{} {}".format(x, result))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = set(map(int, input().split()))

if len(a) == 1:
    result = list(a)[0]
    print("{} {}".format(result, result))

x = max(a)
result = min(a)
for i in a:
    if i == (x // 2):
        break
    elif i < x / 2:
        result = i
    elif (i - x / 2) < (x / 2 - result):
        result = i
        break
    else:
        break

print("{} {}".format(x, result))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
max_a = max(a)
min_diff = 1000000000
for i in range(n):
    if min_diff > abs(max_a / 2 - a[i]):
        min_diff = abs(max_a / 2 - a[i])
        half_a = a[i]
print(max_a, half_a)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse = True)
N = a[0]
for i in range(0,n):
    if int((N+1)/2) > a[i]:
        if(int((N+1)/2)-a[i]) < -(int((N+1)/2)+a[i-1]):
            print(N,a[i])
        else:
            print(N,a[i-1])
        break
    if(i == n-1):
        print(N,a[i])
        break

Submission status: Wrong Answer

Solution code:
import bisect

n = int(input())
a = list(map(int, input().split()))
a.sort()
pos = bisect.bisect_left(a, max(a)/2)
if pos == n-1:
    print(a[-1], a[-2])
else:
    c1 = abs(a[-1]/2 - a[pos-1])
    c2 = abs(a[-1]/2 - a[pos])
    c3 = abs(a[-1]/2 - a[pos+1])
    if c1 == min(c1, c2, c3):
        print(a[-1], a[pos-1])
    if c2 == min(c1, c2, c3):
        print(a[-1], a[pos])
    if c3 == min(c1, c2, c3):
        print(a[-1], a[pos+1])

Submission status: Wrong Answer

Solution code:
import bisect

n = int(input())
a = list(map(int, input().split()))
a.sort()
pos = bisect.bisect_left(a, max(a)//2)
if pos == n-1:
    print(a[-1], a[-2])
else:
    c1 = abs(a[-1]/2 - a[pos-1])
    c2 = abs(a[-1]/2 - a[pos])
    c3 = abs(a[-1]/2 - a[pos+1])
    if c1 == min(c1, c2, c3):
        print(a[-1], a[pos-1])
    if c2 == min(c1, c2, c3):
        print(a[-1], a[pos])
    if c3 == min(c1, c2, c3):
        print(a[-1], a[pos+1])

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import math

N = int(input())
number_list = list(map(int, input().split()))


def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

max_value = 0
max_list_value = max(number_list)

for j in range(len(number_list)):
    combinations_count_value = \
        combinations_count(max_list_value, number_list[j])
    if max_value < combinations_count_value:
        max_value = combinations_count_value
        value_pair = [max_list_value, number_list[j]]

print('{} {}'.format(value_pair[0], value_pair[1]))

Submission status: Wrong Answer

Solution code:
n = int(input())
a_n = list(map(int, input().split()))
result1 = max(a_n)
min_delta = max(a_n)
result2 = max(a_n)
for num in a_n:
    if abs(num-result1/2)<min_delta:
        min_delta = abs(num-result1/2)
        result2 = num
print('{} {}'.format(result1, result2))

Submission status: Wrong Answer

Solution code:
n = int(input())
a_n = list(map(int, input().split()))
result1 = max(a_n)
min_delta = max(a_n)
result2 = max(a_n)
for num in a_n:
    if abs(num-n/2)<min_delta:
        result2 = num
print('{} {}'.format(result1, result2))

Submission status: Wrong Answer

Solution code:
N = int(input())
list = list(map(int,input().split()))
#print(list)
sa_list = []
ai = max(list)
for i in range(N):
    sa2 = abs(( list[i] - ai/2 ) *2)
    
   #print(sa)
    sa_list.append(int(sa2))
#print(sa_list)
basyo = (sa_list.index(min(sa_list)))
ar = list[basyo]
print(str((ai)) + " " + str((ar)))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list( map(int, input().split()))

max = max(a)
b = [abs( max/2 - a[i]) for i in range(n)]

minb = min(b)
index = b.index(minb)

print(max, end = ' ')
print(a[index])

Submission status: Wrong Answer

Solution code:
n = int(input())
x = [int(i) for i in input().split()]

x.sort()
mx = x[n-1]
print(mx," ",sep="",end="")
i = 1
while True:
    if x[i] - mx/2 >= 0:
        break
    i += 1
if mx/2 - x[i-1] < x[i] - mx/2:
    print(x[i-1])
else:
    print(x[i])

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
# kakomon toku
import math
import sys
import itertools
import numpy as np

n = int(input())
a = [int(i) for i in input().split()]
#print(a)
ai=0
for i in range(n):
    if ai < a[i]:
        ai = a[i]
a = np.sort(a)
aj = a[0]
ac = ai / 2
diff = ac
for i in range(n-1):
    if diff > abs(a[i] - ac) :
        aj = a[i]
        diff = abs(aj - ac)
    else:
        break

print(ai,aj)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
# kakomon toku
import math
import sys
import itertools
import numpy as np

n = int(input())
a = [int(i) for i in input().split()]
#print(a)
ai=0
for i in range(n):
    if ai < a[i]:
        ai = a[i]
aj = a[0]
ac = ai / 2
diff = ac
a = np.sort(a)
for i in range(n-1):
    if diff > abs(a[i] - ac) :
        aj = a[i]
        diff = abs(aj - ac)
    else:
        break

print(ai,aj)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
# kakomon toku
import math
import sys
import itertools
import numpy as np

n = int(input())
a = [int(i) for i in input().split()]
#print(a)
ai=0
for i in range(n):
    if ai < a[i]:
        ai = a[i]
aj = ai
ac = ai / 2
diff = ac
for i in range(n):
    if diff > abs(a[i] - aj) :
        aj = a[i]
        diff = abs(aj - ac)
if(ai==aj):
    aj=0
print(ai,aj)

Submission status: Wrong Answer

Solution code:
N=int(input())
A=[int(i) for i in input().split()]
M=max(A)
S=10**9
j=0
for i in range(N):
  if S>abs(2*A[i]-M):
    j=i
    S=abs(2*A[j]-M)
print(M,A[j])

Submission status: Wrong Answer

Solution code:
N=int(input())
A=[int(i) for i in input().split()]
M=max(A)
S=0
j=0
for i in range(N):
  if S>abs(2*A[i]-M):
    j=i
    S=abs(2*A[j]-M)
print(M,A[j])

Submission status: Wrong Answer

Solution code:
n = int(input())
numList = list(map(int, input().split()))

lastNum = max(numList)

if n > 2:
	bestNum = int(lastNum/2)
	searchNum1 = bestNum
	searchNum2 = bestNum
	while True:
		if searchNum1 in numList:
			flg = True
			break
		if searchNum2 in numList:
			flg = False
			break
		searchNum1 += 1
		searchNum2 -= 1

	if flg:
		print(str(lastNum)+" "+str(searchNum1))
	else:
		print(str(lastNum)+" "+str(searchNum2))
else:
	print(str(numList[1])+" "+str(numList[0]))

Submission status: Wrong Answer

Solution code:
n = int(input())
numList = list(map(int, input().split()))


def comb(n1, n2):
	result = 1
	for x in range(n1-n2+1,n1+1):
		result = result * x
	for x in range(1,n2+1):
		result = result / x
	return int(result)

numList = sorted(numList)
lastNum = numList[len(numList)-1]

if n > 2:
	if n%2 == 0:
		medIndex1 = int((n)/2)
		medIndex2 = medIndex1 - 1
		medNum1 = numList[medIndex1]
		medNum2 = numList[medIndex2]
		comb1 = comb(medNum1, lastNum)
		comb2 = comb(medNum2, lastNum)
		if comb1 > comb2:
			print(str(lastNum)+" "+str(medNum1))
		else:
			print(str(lastNum)+" "+str(medNum2))
	else:
		medIndex = int((n)/2)
		medNum = numList[medIndex]
		print(str(lastNum)+" "+str(medNum))
else:
	print(str(numList[1])+" "+str(numList[0]))

Submission status: Wrong Answer

Solution code:
n = int(input())
numList = list(map(int, input().split()))


def comb(n1, n2):
	result = 1
	for x in range(n1-n2+1,n1+1):
		result = result * x
	for x in range(1,n2+1):
		result = result / x
	return int(result)

numList = sorted(numList)
lastNum = numList[len(numList)-1]

if n > 2:
	if n%2 == 0:
		medIndex1 = int((n)/2)
		medIndex2 = medIndex1 - 1
		medNum1 = numList[medIndex1]
		medNum2 = numList[medIndex2]
		comb1 = comb(medNum1, lastNum)
		comb2 = comb(medNum2, lastNum)
		if comb1 > comb2:
			print(str(medNum1)+" "+str(lastNum))
		else:
			print(str(medNum2)+" "+str(lastNum))
	else:
		medIndex = int((n)/2)
		medNum = numList[medIndex]
		print(str(medNum)+" "+str(lastNum))
else:
	print(str(numList[0])+" "+str(numList[1]))

Submission status: Wrong Answer

Solution code:
N=int(input())
s=list(map(int,input().split()))
n=max(s)
s.remove(n)
q=n
for i in s:
    t=abs(n//2-i)
    if q>=t:
        q=t
        w=str(n)+" "+str(i)
print(w)

Submission status: Wrong Answer

Solution code:
N=int(input())
s=list(map(int,input().split()))
n=max(s)
s.remove(n)
q=n
for i in s:
    t=n//2-i
    if q>=t:
        q=t
        w=str(n)+" "+str(i)
print(w)

Submission status: Wrong Answer

Solution code:
numbers=int(input())
list_num=[int(i) for i in input().split()]

bigger_num=max(list_num)
smaller_num=int(bigger_num/2)

for i in range(0, smaller_num):
    if smaller_num + i in list_num:
        smaller_num = smaller_num + i
        break
    elif smaller_num - i in list_num:
        smaller_num = smaller_num - i
        break

print(bigger_num, smaller_num)

Submission status: Wrong Answer

Solution code:
def binary_search(list, item):
    length = len(list)
    if length == 1:
        return list[0]
    if length == 2:
        err0 = abs(item - list[0])
        err1 = abs(item - list[1])
        return list[0] if err0 < err1 else list[1]
    else:
        mid_pos = len(list) // 2
        if list[mid_pos] == item:
            return item
        elif list[mid_pos] > item:
            return binary_search(list[:mid_pos+1], item)
        else:
            return binary_search(list[mid_pos:], item)


def search(list, item, n):
    for i in range(n-1):
        if list[i] > item:
            if i == 0:
                return list[0]
            if i == n - 2:
                return list[n-2]
            err_left = item - list[i-1]
            err_right = list[i] - item
            return list[i-1] if err_left < err_right else list[i]
    

n = int(input())
a = list(map(int, input().split()))
a.sort()
a_i = a[n-1]
half = a_i / 2
a_j = search(a[:-1], half, n)
print('{} {}'.format(a_i, a_j))

Submission status: Wrong Answer

Solution code:
def binary_search(list, item):
    length = len(list)
    if length == 1:
        return list[0]
    elif length == 2:
        err0 = abs(item - list[0])
        err1 = abs(item - list[1])
        return list[0] if err0 < err1 else list[1]
    else:
        mid_pos = len(list) // 2
        if list[mid_pos] == item:
            return item
        elif list[mid_pos] > item:
            return binary_search(list[:mid_pos+1], item)
        else:
            return binary_search(list[mid_pos:], item)


n = int(input())
a = list(map(int, input().split()))
a.sort()
a_i = a[n-1]
half = a_i / 2
a_j = binary_search(a[:-1], half)
print('{} {}'.format(a_i, a_j))

Submission status: Wrong Answer

Solution code:
def binary_search(list, item):
    length = len(list)
    if length == 1:
        return list[0]
    elif length == 2:
        err0 = item - list[0]
        err1 = list[1] - item
        return list[0] if err0 < err1 else list[1]
    else:
        mid_pos = len(list) // 2
        if list[mid_pos] == item:
            return item
        elif list[mid_pos] > item:
            return binary_search(list[:mid_pos+1], item)
        else:
            return binary_search(list[mid_pos:], item)


n = int(input())
a = list(map(int, input().split()))
a.sort()
a_i = a[n-1]
half = a[n-1] / 2
a_j = binary_search(a[:-1], half)
print('{} {}'.format(a_i, a_j))

Submission status: Wrong Answer

Solution code:
n=int(input())
a=input().split()
a=[int(aa) for aa in a]
m=max(a)
b=sorted(a)
r=b[int(n/2)] if n%2==1 else min(b[int(n/2-1)],b[int(n/2)])
print("{} {}".format(m, r))

Submission status: Wrong Answer

Solution code:
def comb(x, y):
    return math.factorial(x) / (math.factorial(x - y) * math.factorial(y))

def solve(N, AS):
    x = max(AS)
    y = min(map(lambda z: [abs(z - x / 2), z] , AS), key=lambda x: x[0])[1]
    return (x, y)

if __name__ == '__main__':
    n = int(input())
    AS  = list(map(lambda x: int(x), input().split()))
    tmp = solve(n, AS)
    print(tmp[0], tmp[1])

Submission status: Wrong Answer

Solution code:
def comb(x, y):
    return math.factorial(x) / (math.factorial(x - y) * math.factorial(y))

def solve(N, AS):
    x = max(AS)
    y = min(map(lambda z: [abs(z - x / 2), z] , AS), key=lambda x: x[0])[1]
    return (x, y)

if __name__ == '__main__':
    n = int(input())
    AS  = list(map(lambda x: int(x), input().split()))
    print(solve(n, AS))

Submission status: Wrong Answer

Solution code:
n = int(input())
x = list(map(int,input().split()))
y = sorted(x)
x1, x2 = y[n//2-1], y[n//2]
for i, yy in enumerate(y):
    if i >= n:
        break
    if yy<=x1:
        print(x2)
    else:
        print(x1)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = sorted(list(map(int, input().split())))

import bisect

arg_max_i = bisect.bisect_left(a, a[n-1] // 2)

if a[arg_max_i] == a[n-1]:
  arg_max_i -= 1

print(a[n-1], a[arg_max_i])

Submission status: Wrong Answer

Solution code:
n = int(input())
a = sorted(list(map(int, input().split())))

import bisect

arg_max_i = bisect.bisect_left(a, a[n-1] / 2)

print(a[n-1], a[arg_max_i])

Submission status: Wrong Answer

Solution code:
n = int(input())
a = sorted(list(map(int, input().split())))

print(n, a)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
m = max(a)
print(m,min(a,key=lambda x:abs(m-x*2)))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
i = max(a)
j = min(a, key=lambda x:abs(i - x * 2))
print('{} {}'.format(i, j))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
i = max(a)
j = min(a, key=lambda x:abs(i - x*2))
print(i, j)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = input().split(" ")
for i in range(n):
    a[i] = int(a[i])
a.sort()
ans_bef = max(a)
ans_aft = a[0]
med = 11/2
for i in range(1, n-1):
    if abs(med-a[i]) < abs(med-ans_aft):
        ans_aft = a[i]
print(ans_bef, ans_aft)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
a.sort()

b=a[:]
c=a[-1]

print('c',c)


for i in range(len(a)):
    a[i]=abs(a[i]-int((c+1)/2))

for j in range(len(a)):
    print(a[j])


ans = b[a.index(min(a))]

print('ans',ans)


print(b[-1],ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)

b=a[:]
c=a[0]

for i in range(len(a)):
    a[i]=abs(a[i]-(c+1)/2)

ans = b[a.index(min(a))]
print(b[0],ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
ai = max(a)
aj = min(a, key=lambda x: abs(x-ai//2))
print("{} {}".format(ai, aj))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))

a = sorted(a)

r = 0
minV = 10**10
for i in range(max(0,n//2-2),min(n-1,n//2+2)):
	curr = abs(a[-1] / 2 - a[i])
#	print(a[-1],a[i],curr)
	if minV > curr:
		r = a[i]
		minV = curr

print(a[-1], r)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))

a = sorted(a)

r = 0
minV = 10**10
for i in range(max(0,n//2-2),min(n-1,n//2+2)):
	curr = abs(a[-1] - 2 * a[i])
	if minV > curr:
		r = a[i]
		minV = curr

print(a[-1], r)

Submission status: Wrong Answer

Solution code:
def ans():
    n = int(input())
    a = list(map(int, input().split()))

    def comb(x, y):
        c = 1
        p = 1
        for i in range(y, 0, -1):
            c = c * i
        for i in range(x, x - y, -1):
            p = p * i
        return p / c

    p = max(a)
    a.remove(p)
    tmp = 1
    tmpdiff = 9999999
    for i in a:
        if abs(tmpdiff - p / 2) > abs(i - p / 2):
            tmpdiff = i
        # diff = abs(i - want_near)
        # if diff == want_near:
        #     return "{0} {1}".format(p, i)
        # if diff < tmpdiff:
        #     tmpdiff = diff
        #     tmp = i

    return "{0} {1}".format(p, tmpdiff)


print(ans())

Submission status: Wrong Answer

Solution code:
def ans():
    n = int(input())
    a = list(map(int, input().split()))

    def comb(x, y):
        c = 1
        p = 1
        for i in range(y, 0, -1):
            c = c * i
        for i in range(x, x - y, -1):
            p = p * i
        return p / c

    p = max(a)
    a.remove(p)
    tmp = 1
    tmpdiff = 9999999
    for i in a:
        if abs(tmpdiff - p / 2) > abs(i - p / 2):
            tmpdiff = i 
        # diff = abs(i - want_near)
        # if diff == want_near:
        #     return "{0} {1}".format(p, i)
        # if diff < tmpdiff:
        #     tmpdiff = diff
        #     tmp = i

    return "{0} {1}".format(p, tmp)


print(ans())

Submission status: Wrong Answer

Solution code:
def ans():
    n = int(input())
    a = list(map(int, input().split()))

    def comb(x, y):
        c = 1
        p = 1
        for i in range(y, 0, -1):
            c = c * i
        for i in range(x, x - y, -1):
            p = p * i
        return p / c

    p = max(a)
    a.remove(p)
    tmp = 1
    tmpdiff = 9999999

    if p % 2 == 0:
        want_near = p // 2
        for i in a:
            diff = abs(i - want_near)
            if diff == want_near:
                return "{0} {1}".format(p, i)
            if diff < tmpdiff:
                tmpdiff = diff
                tmp = i
    else:
        want_near = p // 2
        want_near_1 = want_near + 1
        for i in a:
            diff = abs(i - want_near)
            if diff == want_near or diff ==want_near_1:
                return "{0} {1}".format(p, i)
            if diff < tmpdiff:
                tmpdiff = diff
                tmp = i

    return "{0} {1}".format(p, tmp)


print(ans())