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()))

nb=0
b=0
mn=max(a)
def comb(n, r):
    r = min(r, n-r)
    numerator = 1
    for i in range(n, n-r, -1):
        numerator *= i
    denominator = 1
    for i in range(r, 1, -1):
        denominator *= i

    return numerator // denominator

for i in a:
    if comb(mn,i) >b:
        b=comb(mn,i)
        nb=i
print(max(a),nb)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
a.sort()
a_i = a[-1]
a_j = a[0]
max = 0
import numpy as np
def getNearestValue(list, num):
    """
    概要: リストからある値に最も近い値を返却する関数
    @param list: データ配列
    @param num: 対象値
    @return 対象値に最も近い値
    """

    # リスト要素と対象値の差分を計算し最小値のインデックスを取得
    idx = np.abs(np.asarray(list) - num).argmin()
    return list[idx]

from scipy.misc import comb
if n - 10 < 0:
    n_min = 0
else:
    n_min = n - 10
for i in range(n_min,n):
    if a[i]%2 == 0:
        b_j = getNearestValue(a, a[i]/2)
        b1 = comb(a[i], b_j)
        if max < b1 and a[i] > b_j:
            max = b1
            a_i = a[i]
            a_j = b_j
    else:
        b_j = getNearestValue(a, (a[i]-1)/2)
        b1 = comb(a[i], b_j)
        if max < b1 and a[i] > b_j:
            max = b1
            a_i = a[i]
            a_j = b_j
        b_j = getNearestValue(a, (a[i]+1)/2)
        b1 = comb(a[i], b_j)
        if max < b1 and a[i] > b_j:
            max = b1
            a_i = a[i]
            a_j = b_j
print("{} {}".format(a_i, a_j))

Submission status: Wrong Answer

Solution code:
da = int(input())
ta = list(map(int,input().split()))

ta.sort()

k = ta[da - 1]

l = k // 2

for l in range(da - 2):
  if ta[l] >= l:
    ta[l] = k - ta[l]

ta.sort()
print(ta)
print(ta[da -1],ta[0])

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
a.sort()
a_i = a[-1]
a_j = a[0]
max = 0
import numpy as np
def getNearestValue(list, num):
    """
    概要: リストからある値に最も近い値を返却する関数
    @param list: データ配列
    @param num: 対象値
    @return 対象値に最も近い値
    """

    # リスト要素と対象値の差分を計算し最小値のインデックスを取得
    idx = np.abs(np.asarray(list) - num).argmin()
    return list[idx]

from scipy.misc import comb
for i in range(n-2,n):
    if a[i]%2 == 0:
        b_j = getNearestValue(a, a[i]/2)
        b1 = comb(a[i], b_j)
        if max < b1 and a[i] > b_j:
            max = b1
            a_i = a[i]
            a_j = b_j
    else:
        b_j = getNearestValue(a, (a[i]-1)/2)
        b1 = comb(a[i], b_j)
        if max < b1 and a[i] > b_j:
            max = b1
            a_i = a[i]
            a_j = b_j
        b_j = getNearestValue(a, (a[i]+1)/2)
        b1 = comb(a[i], b_j)
        if max < b1 and a[i] > b_j:
            max = b1
            a_i = a[i]
            a_j = b_j
print("{} {}".format(a_i, a_j))

Submission status: Wrong Answer

Solution code:
def ncr(n, r):
    r = min(r, n - r)
    if r == 0: return 1;
    if r == 1: return n;
    numerator = [n - r + i + 1 for i in range(r)]
    denominator = [i + 1 for i in range(r)]
    for p in range(2, r + 1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p - 1, r, p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot
    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= numerator[k]
    return result


n = int(input())
array = [int(x) for x in input().split()]

array2 = array[n // 2 - 2:n // 2 + 2]
tmp = 0
res = min(array)
for i in array2:
    tmp2 = ncr(max(array), i)
    if tmp < tmp2:
        tmp = tmp2
        res = i
print(max(array), res)

Submission status: Wrong Answer

Solution code:
from itertools import combinations

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

def fastcomb(n,r):
    
    if n-r<r:r= n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n-r+k+1 for k in range(r)]
    denominator = [k+1 for k in range(r)]
    
    for p in range(2, r+1):
        pivot = denominator[p-1]
        if pivot>1:
            offset = (n-r)%p
            for k in range(p-1, r, p):
                numerator[k-offset]/=pivot
                denominator[k]/=pivot
    

    result = 1
    for k in range(r):
        if numerator[k]>1: result *= numerator[k]


    return int(result)


li = list(combinations(a, 2))

def comb(x,y):
    p = [x,y]
    p.sort()
    return fastcomb(p[1], p[0])
    
comblist = [comb(x,y) for x,y in li]

answer = list(li[[i for i,k in enumerate(comblist) if k==max(comblist)][0]])
answer.sort()
answer.reverse()

print(answer)

Submission status: Wrong Answer

Solution code:
import scipy.misc as scm

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

a = sorted(a, reverse=True)

comb = -1
for i in range(n-1):
    if scm.comb(a[i], int(a[i]/2)) <= comb:
        break
    if a[i] % 2 == 0:
        max_r = int(a[i]/2)
        if max_r in a:
            c = scm.comb(a[i], max_r)
            if c < comb:
                break
            else:
                a_i = a[i]
                a_j = max_r
                comb = c
        else:
            r_list = a[i+1:]
            tmp_c = -1
            for r in r_list:
                c = scm.comb(a[i], r)
                if tmp_c < c:
                    tmp_c = c
                    tmp_r = r
                else:
                    break
            if tmp_c > comb:
                a_i = a[i]
                a_j = tmp_r
                comb = tmp_c
    else:
        max_r1 = int(a[i]/2)
        max_r2 = int(a[i]/2)+1
        if max_r1 in a:
            c = scm.comb(a[i], max_r1)
            if c < comb:
                break
            else:
                a_i = a[i]
                a_j = max_r1
                comb = c
        elif max_r2 in a:
            c = scm.comb(a[i], max_r2)
            if c < comb:
                break
            else:
                a_i = a[i]
                a_j = max_r2
                comb = c
        else:
            r_list = a[i+1:]
            tmp_c = -1
            for r in r_list:
                c = scm.comb(a[i], r)
                if tmp_c < c:
                    tmp_c = c
                    tmp_r = r
                else:
                    break
            if tmp_c > comb:
                a_i = a[i]
                a_j = tmp_r
                comb = tmp_c
print(a_i, a_j)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
a.sort()
max_a=a[n-1]
N=int(n/2)-1
max_b=a[N]
resu=[0,N,n-2]
while resu[2]-resu[0]>2:
    if max_b-max_a/2>0:
        resu[2]=N
        N=int((resu[0]+resu[1])/2)
        resu[1]=N
        max_b=a[N]
    elif max_b==max_a/2:
        break
    else:
        resu[0]=N
        N=int((resu[1]+resu[2])/2)
        resu[1]=N
        max_b=a[N]
        
print(max_a,a[resu[1]])

Submission status: Wrong Answer

Solution code:
import scipy.misc as scm
N=int(input())
a=list(map(int,input().split()))

nb=0
b=0
mn=max(a)
for i in a:
    if scm.comb(mn,i,1) >b:
        b=scm.comb(mn,i,1)
        nb=i
print(max(a),nb)

Submission status: Wrong Answer

Solution code:
import scipy.misc as scm

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

a = sorted(a, reverse=True)

comb = -1
for i in range(n-1):
    if a[i] % 2 == 0:
        max_r = int(a[i]/2)
        if max_r in a:
            c = scm.comb(a[i], max_r)
            if c < comb:
                break
            else:
                a_i = a[i]
                a_j = max_r
                comb = c
        else:
            r_list = a[i+1:]
            tmp_c = -1
            for r in r_list:
                c = scm.comb(a[i], r)
                if tmp_c < c:
                    tmp_c = c
                    tmp_r = r
                else:
                    break
            if tmp_c > comb:
                a_i = a[i]
                a_j = tmp_r
                comb = tmp_c
            else:
                break
    else:
        max_r1 = int(a[i]/2)
        max_r2 = int(a[i]/2)+1
        if max_r1 in a:
            c = scm.comb(a[i], max_r1)
            if c < comb:
                break
            else:
                a_i = a[i]
                a_j = max_r1
                comb = c
        elif max_r2 in a:
            c = scm.comb(a[i], max_r2)
            if c < comb:
                break
            else:
                a_i = a[i]
                a_j = max_r2
                comb = c
        else:
            r_list = a[i+1:]
            tmp_c = -1
            for r in r_list:
                c = scm.comb(a[i], r)
                if tmp_c < c:
                    tmp_c = c
                    tmp_r = r
                else:
                    break
            if tmp_c > comb:
                a_i = a[i]
                a_j = tmp_r
                comb = tmp_c
            else:
                break
print(a_i, a_j)

Submission status: Wrong Answer

Solution code:
import bisect
import math
n = int(input())
a = list(map(int,input().split()))
a.sort()
ans = [0,0]
max = 0
i = n-1
if n == 2:
	ans[0] = a[0]
	ans[1] = a[1]
else:
	while i >= (5*n//6-1):
		if a[i]%2 == 0:
			temp = n-1
			while a[i]//2 < a[temp]:
				temp += -1
			
			if a[i] > a[temp-1]:
				if (a[i]//2-a[temp-1]) <= (a[temp+1]-a[i]//2):
					tmax = (math.factorial(a[i]))/(math.factorial(a[i]-a[temp-1])*math.factorial(a[temp-1]))
					if max < tmax:
						max = tmax
						ans[0] = a[i]
						ans[1] = a[temp-1]
				else:
					tmax = (math.factorial(a[i]))/(math.factorial(a[i]-a[temp+1])*math.factorial(a[temp+1]))
					if max < tmax:
						max = tmax
						ans[0] = a[i]
						ans[1] = a[temp+1]
		else:
			temp1 = n-1
			temp2 = n-1
	
			while (a[i]+1)//2 < a[temp1]:
				temp1 += -1
			while (a[i]-1)//2 < a[temp2]:
				temp2 += -1
			
			if a[i] > a[temp1-1]:
				if (a[i]//2-a[temp1-1]) <= (a[temp1+1]-a[i]//2):
					tmax = (math.factorial(a[i]))/(math.factorial(a[i]-a[temp1-1])*math.factorial(a[temp1-1]))
					if max < tmax:
						max = tmax
						ans[0] = a[i]
						ans[1] = a[temp1-1]
				else:
					tmax = (math.factorial(a[i]))/(math.factorial(a[i]-a[temp1+1])*math.factorial(a[temp1+1]))
					if max < tmax:
						max = tmax
						ans[0] = a[i]
						ans[1] = a[temp1+1]
		
			if a[i] > a[temp2-1]:
				if (a[i]//2-a[temp2-1]) <= (a[temp2+1]-a[i]//2):
					tmax = (math.factorial(a[i]))/(math.factorial(a[i]-a[temp2-1])*math.factorial(a[temp2-1]))
					if max < tmax:
						max = tmax
						ans[0] = a[i]
						ans[1] = a[temp2-1]
				else:
					tmax = (math.factorial(a[i]))/(math.factorial(a[i]-a[temp2+1])*math.factorial(a[temp2+1]))
					if max < tmax:
						max = tmax
						ans[0] = a[i]
						ans[1] = a[temp2+1]
		i += -1
print(ans[0],ans[1])

Submission status: Wrong Answer

Solution code:

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

def f(N, A):
    
    if len(A) == 2:
        A.sort()
        print(A[0], A[1])
        return

    res = 0
    temp = 0
    maxA = max(A)

    for a in A:
        if a == maxA:
            continue
        
        b = min(a, maxA - a)
        if res < b:
            temp = b
            res = a
        
    return print(maxA, res)

f(N, A)

Submission status: Wrong Answer

Solution code:
def comb(a, b):
    ans, x, y = 0, a, b
    for i in range(1, b):
        x *= a-i
        y *= b-i
    ans = int(x/y)
    return ans
    
n= int(input())
a = [int(i) for i in input().split()]
m = max(a)

t = 0
t2 = 0
b = filter(lambda x: m/2-n/2 < x and x < m/2+n/2, a)

for j in b:
    if j == 0:
        continue
    t3 = comb(m, j)
    if t < t3:
        t = t3
        t2 = j
print(str(m)+" "+str(t2))

Submission status: Wrong Answer

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

mv = max(a)
mid = a[0]
for i in range(1, len(a)):
    if abs(mv//2+1 - a[i]) < abs(mv//2+1 - mid):
        mid = a[i]

print(mv, mid)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
a.sort()
max_a=a[n-1]
N=int(n/2)-1
max_b=a[N]
resu=[0,N,n-2]
while resu[2]-resu[0]>2:
    if max_b-max_a/2>0:
        resu[2]=N
        N=int((resu[0]+resu[1]+1)/2)
        resu[1]=N
        max_b=a[N]
    elif max_b==max_a/2:
        break
    else:
        resu[0]=N
        N=int((resu[1]+resu[2]+1)/2)
        resu[1]=N
        max_b=a[N]
        
print(max_a,a[resu[1]])

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(1000000)

max_comb = None
max_value = 0


def memorize(c, value, memo, a):
    global max_comb
    global max_value

    memo[c] = value

    # for answer
    if c[0] != c[1] and \
            c[0] in a and \
            c[1] in a and \
            max_value < memo[c]:
        max_value = memo[c]
        max_comb = c


def comb(a_i, a_j, memo, a):
    c = (a_i, a_j)
    # print(a_i, a_j)

    if c in memo:
        return memo[c]

    if a_j == 1:
        memorize(c, a_i, memo, a)
        return a_i

    if a_i == a_j or a_j == 0:
        memorize(c, 1, memo, a)
        return 1

    value = comb(a_i - 1, a_j, memo, a) + comb(a_i - 1, a_j - 1, memo, a)
    memorize(c, value, memo, a)
    return memo[c]


if __name__ == '__main__':
    # n = int(input())
    # a = list(map(int, input().split()))

    n = 5
    a = [6, 9, 4, 2, 11]

    # find 1st, 2nd
    # max_a, second_max_a = -1, -2
    # for a_i in a:
    #     if max_a < a_i:
    #         second_max_a = max_a
    #         max_a = a_i
    #     elif second_max_a < a_i:
    #         second_max_a = a_i

    max_a = max(a)
    memo = dict()

    for a_i in a:
        if max_a != a_i:
            comb(max_a, a_i, memo, a)
            # comb(max_a, second_max_a, memo, a)
    #
    # for i in range(n - 1):
    #     for j in range(i + 1, n):
    #         comb(a_sorted[i], a_sorted[j], memo, a)
    #
    #         # print("comb:", a_sorted[i], a_sorted[j])

    print(max_comb[0], max_comb[1])

Submission status: Wrong Answer

Solution code:
def combination(n, r):
    res = 1
    for i in range(n - r + 1, n + 1):
        res = res * i / (i - n + r)
    return res

N = int(input())
array = list(map(int, input().split()))
array.sort()
temp = 0
temp_pair = [0, 0]
for e in array:
    half = 0
    for i in range(0, N):
        half = array[i]
        if half > int(e / 2):
            break
    com = combination(e, half)
    if temp < com:
        temp = com
        temp_pair = [e, half]
print("{0} {1}".format(temp_pair[0], temp_pair[1]))

Submission status: Wrong Answer

Solution code:
from statistics import median


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

if n == 2:
    print(max(a), min(a))
else:
    print(max(a), median(a))

Submission status: Wrong Answer

Solution code:
import scipy.misc as scm

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

a = sorted(a, reverse=True)

comb = -1
for i in range(n-1):
    if a[i] % 2 == 0:
        max_r = int(a[i]/2)
        if max_r in a:
            c = scm.comb(a[i], max_r)
            if c < comb:
                break
            else:
                a_i = a[i]
                a_j = max_r
                comb = c
        else:
            r_list = a[i+1:]
            tmp_c = -1
            for r in r_list:
                c = scm.comb(a[i], r)
                if tmp_c < c:
                    tmp_c = c
                    tmp_r = r
                else:
                    break
            if tmp_c > comb:
                a_i = a[i]
                a_j = tmp_r
                comb = tmp_c
            else:
                break
    else:
        max_r1 = int(a[i]/2)
        max_r2 = int(a[i]/2)+1
        if max_r1 in a:
            c = scm.comb(a[i], max_r1)
            if c < comb:
                break
            else:
                a_i = a[i]
                a_j = max_r1
        elif max_r2 in a:
            c = scm.comb(a[i], max_r2)
            if c < comb:
                break
            else:
                a_i = a[i]
                a_j = max_r2
                comb = c
        else:
            r_list = a[i+1:]
            tmp_c = -1
            for r in r_list:
                c = scm.comb(a[i], r)
                if tmp_c < c:
                    tmp_c = c
                    tmp_r = r
                else:
                    break
            if tmp_c > comb:
                a_i = a[i]
                a_j = tmp_r
                comb = tmp_c
            else:
                break
print(a_i, a_j)

Submission status: Wrong Answer

Solution code:
def comb(a, b):
    ans, x, y = 0, a, b
    for i in range(1, b):
        x *= a-i
        y *= b-i
    ans = int(x/y)
    return ans
    
n= int(input())
a = [int(i) for i in input().split()]
m = max(a)

t = 0
t2 = 0

b = filter(lambda x: x > m/4 and x < m*3/4, a)

for j in b:
    if j == 0:
        continue
    t3 = comb(m, j)
    if t < t3:
        t = t3
        t2 = j
print(str(m)+" "+str(t2))

Submission status: Wrong Answer

Solution code:
N = int(input())
a = tuple(int(x) for x in input().split())

def hoge(n, r):
 return n * (min(n-r, r))

n = max(a)
ans = (n, a[0])
for i in a[1:]:
 ans = (n, i) if hoge(*ans) < hoge(n, i) else ans
print(*ans)

Submission status: Wrong Answer

Solution code:
import scipy.misc as scm

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

a = sorted(a, reverse=True)

comb = -1
for i in range(n-1):
    if a[i] % 2 == 0:
        max_r = int(a[i]/2)
        if max_r in a:
            c = scm.comb(a[i], max_r)
            if c < comb:
                break
            else:
                a_i = a[i]
                a_j = max_r
                comb = c
        else:
            r_list = a[i+1:]
            tmp_c = -1
            for r in r_list:
                c = scm.comb(a[i], r)
                if tmp_c < c:
                    tmp_c = c
                    tmp_r = r
                else:
                    break
            if c > comb:
                a_i = a[i]
                a_j = tmp_r
                comb = c
            else:
                break
    else:
        max_r1 = int(a[i]/2)
        max_r2 = int(a[i]/2)+1
        if max_r1 in a:
            c = scm.comb(a[i], max_r1)
            if c < comb:
                break
            else:
                a_i = a[i]
                a_j = max_r1
        elif max_r2 in a:
            c = scm.comb(a[i], max_r2)
            if c < comb:
                break
            else:
                a_i = a[i]
                a_j = max_r2
                comb = c
        else:
            r_list = a[i+1:]
            tmp_c = -1
            for r in r_list:
                c = scm.comb(a[i], r)
                if tmp_c < c:
                    tmp_c = c
                    tmp_r = r
                else:
                    break
            if c > comb:
                a_i = a[i]
                a_j = tmp_r
                comb = c
            else:
                break
print(a_i, a_j)

Submission status: Wrong Answer

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

mv = max(a)
mid = a[0]
for i in range(1, len(a)):
    if abs(mv//2 - a[i]) < abs(mv//2 - mid):
        mid = a[i]

print(mv, mid)

Submission status: Wrong Answer

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

ai = sortx[n-1]
mid = float(ai)/2
x2 = sorted(abs(k - mid)for k in x)[0]

if (mid + x2) in x:
    aj = int(mid - x2)
else:
    aj = int(mid + x2)

print(ai," ",aj)

Submission status: Wrong Answer

Solution code:
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().strip()

n = ni()
a = na()

if n == 2:
    if a[0] > a[1]:
        print(a[0],a[1])
    else:
        print(a[1],a[0])
else:
    x = max(a)
    mid = x / 2
    a.remove(x)

    diff = mid - a[0]
    ans = 0
    for i in range(len(a)):
        if diff > abs(mid - a[i]):
            diff = abs(mid - a[i])
            ans = i
    print(x,a[ans])

Submission status: Wrong Answer

Solution code:
n = int(input())

N = [int(i) for i in input().split()]
N_max = max(N)
if N_max % 2 == 0:
    N_mid = N_max / 2
else:
    N_mid = (N_max+1) / 2
d = 100000000
ans = 0
for i in range(n):
    if N[i] == N_max:
        continue
    a = abs(N_mid-N[i])
    if d > a:
        ans = N[i]
        d = a
        
print(N_max,ans)

Submission status: Wrong Answer

Solution code:
import math
 
def comb(n,r):
    return int(math.factorial(n)/(math.factorial(r)*math.factorial(n-r)))

def deff_half(l, h):
    d = abs(h - l[0])
    r = 0
    for i in range(1, len(l)):
        if d > abs(h - l[i]):
            d = abs(h - l[i])
            r = i
    return l[r]
    
n = int(input())
x = list(map(int, input().split(" ")))
 
a = max(x)
result = deff_half(x, a/2)

print(a , result)

Submission status: Wrong Answer

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

ai = sortx[n-1]
mid = float(ai)/2
x2 = sorted(abs(k - mid)for k in x)[0]

if (mid + x2) in x:
    aj = int(mid + x2)
else:
    aj = int(mid - x2)

print(ai," ",aj)

Submission status: Wrong Answer

Solution code:
def abc094D():
    import numpy as np
    n = int(input())
    a = list(map(float, input().split()))
    a.sort()

    if len(a) == 2:
        print(a[1], a[0])
        return 0

    a = np.array(a)
    ai = a[-1]

    b = a.copy() - ai / 2
    j = np.argmin(abs(b))
    print(int(ai), int(a[j]))


abc094D()

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
a.sort()
max_a=a[n-1]
N=int(n/2)
max_b=a[N]
resu=[0,N,n-1]
while resu[2]-resu[0]<=1:
    if max_b-max_a/2>0:
        resu[2]=N
        N=int((resu[0]+resu[1]+1)/2)
        resu[1]=N
        max_b=a[N]
    elif max_b==max_a/2:
        break
    else:
        resu[0]=N
        N=int((resu[1]+resu[2]+1)/2)
        resu[1]=N
        max_b=a[N]
        
print(max_a,a[resu[1]])

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
import numpy as np
import scipy.misc as sc
def getNearestValue(listA, num):
    idx = np.abs(np.asarray(listA) - num).argmin()
    return listA[idx]
    
input()
List=list(map(int,input().split()))
n=max(List)
r=getNearestValue(List,n/2)
print(n,r)

Submission status: Wrong Answer

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

biggest = max(a)
base = biggest / 2

res = None
diff = float("inf")
for elem in a:
    if diff > abs(base - elem):
        diff = abs(base - elem)
        res = elem
print(biggest, res)

Submission status: Wrong Answer

Solution code:
n=int(input())
A=sorted(list(map(int,input().split())))
x=A[n-1]
y=A[int(n/2)]
print(x,y)

Submission status: Wrong Answer

Solution code:
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().strip()

n = ni()
a = na()

if n == 2:
    print(a[0],a[1])
x = max(a)
mid = x / 2
a.remove(x)

diff = mid - a[0]
ans = 0
for i in range(len(a)):
    if diff > abs(mid - a[i]):
        diff = abs(mid - a[i])
        ans = i
print(x,a[ans])

Submission status: Wrong Answer

Solution code:
def abc094D():
    import numpy as np
    n = int(input())
    a = list(map(float, input().split()))
    a.sort()

    if len(a) == 2:
        print(a[1], a[0])
        return 0

    a = np.array(a)
    ai = a[-1]

    a -= ai / 2
    aj = min(abs(a) + ai / 2)
    print(int(ai), int(aj))


abc094D()

Submission status: Wrong Answer

Solution code:
def comb(n,r):
    result=1
    for i in range(r):
        result*=(n-r+i+1)/(i+1)
    return(result)
n=int(input())
a=list(map(int,input().split()))
a.sort()
max_a=a[n-1]
N=int(n/2)
max_b=a[N]
resu=[0,N,n-1]
while resu[2]-resu[0]<=1:
    if max_b-max_a/2>0:
        resu[2]=N
        N=int((resu[0]+resu[1]+1)/2)
        resu[1]=N
    elif max_b==max_a/2:
        break
    else:
        resu[0]=N
        N=int((resu[1]+resu[2]+1)/2)
        resu[1]=N
        
print(max_a,a[resu[1]])

Submission status: Wrong Answer

Solution code:
n_ = int(input())
a = [int(i) for i in input().split()]

n = max(a)
r = n

for i in a:
    if abs(r-int(n/2)) > abs(i-int(n/2)):
        r = i

print(n, r)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
a.sort()
a_i = a[-1]
max = 0
b = 0
from scipy.misc import comb
for i in a[0:-2]:
    buf = comb(a_i,i)
    if max < buf:
        max = buf
        b = i
    else:
        break
print("{} {}".format(a_i, b))

Submission status: Wrong Answer

Solution code:

def abc094D():
    import numpy as np
    n = int(input())
    a = list(map(int, input().split()))
    a.sort()
    if len(a) == 2:
        print(a[1], a[0])
        return 0
    a = np.array(a)
    ai = a[-1]
    a -= ai // 2
    aj = min(abs(a) + ai // 2)
    print(ai, aj)


abc094D()

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
a.sort()
a_i = a[-1]
max = 0
b = 0
from scipy.misc import comb
for i in a[0:-2]:
    buf = comb(a_i,i)
    if max < buf:
        max = buf
        b = i
    else:
        b = i
        break
print("{} {}".format(a_i, b))

Submission status: Wrong Answer

Solution code:
n=int(input())
A=list(map(int,input().split()))
x=max(A)
y=A[0]
mid=x/2
dis=abs(mid-y)
for i in range(1,n):
    if abs(mid-A[i])<dis:
        y=A[i]
        dis=abs(mid-y)
print(x,y)

Submission status: Wrong Answer

Solution code:
from math import factorial
from scipy.misc import comb
n = int(input())
a = [int(i) for i in input().split()]
sa = sorted(a,reverse=True)
sb = sa[1:]
l = n - 1
n = sa[0]
if l % 2 == 0 or l == 1:
    a1 = sb[l//2 - 1]
    a2 = sb[l//2]
    p = [comb(n,a1),comb(n,a2)]
else:
    a1 = sb[l//2 - 1]
    a2 = sb[l//2]
    a3 = sb[l//2 + 1]
    p = [comb(n,a1),comb(n,a2), comb(n,a3)]

m = max(p)
i =p.index(m)
if  i == 0:
    print(n, a1)
elif i == 1:
    print(n, a2)
else:
    print(n, a3)

Submission status: Wrong Answer

Solution code:
import sys, math
n = int(input())
a = list(map(int, input().split(' ')))

n = max(a)
a.remove(n)
res = 0
prev = 9999999999
for k in a:
    buf = (math.factorial(n) / (math.factorial(k) * math.factorial(n-k)))
    if buf > res:
        res = buf
    elif prev >= res:
        print(n, res)
        sys.exit(0)
    prev = buf

Submission status: Wrong Answer

Solution code:
import sys, math
n = int(input())
a = list(map(int, input().split(' ')))

n = max(a)
a.remove(n)
res = 0
prev = 9999999999
for k in a:
    buf = (math.factorial(n) / (math.factorial(k) * math.factorial(n-k)))
    if buf > res:
        res = buf
    elif prev >= res:
        print(n, res)
        sys.exit(0)

Submission status: Wrong Answer

Solution code:
import math

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

a_max = 0

for ai in a:
    a_max = max(a_max, ai)

if a[0] != a_max:
    m = a[0]
else:
    m = a[1]

for ai in a:
    if ai == a_max or ai == m:
        continue

    if ai < n - m:
        m = ai

print(a_max, m)

Submission status: Wrong Answer

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

p = max(a)
q = max(a)
for i in range(n):
    m = abs(a[i]-p/2)
    if m < abs(q-p/2):
        q = a[i]
        

print(p,q)

Submission status: Wrong Answer

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

n = max(a)
a.remove(n)
res = 0
for k in a:
    buf = (math.factorial(n) / (math.factorial(k) * math.factorial(n-k)))
    if buf < res:
        res = buf

print(n, res)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
a.sort()
a_i = a[-1]
a_i_2 = a_i / 2.0
b = a[0]
for i in a:
    if i < a_i_2:
        b = i
    elif i != a_i:
        c = i
        break
    else:
        c = b
        break
from scipy.misc import comb
if comb(a_i, b) > comb(a_i,c):
    print("{} {}".format(a_i, b))
else:
    print("{} {}".format(a_i, c))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
a.sort()
a = a[::-1]
print(a[0], a[n//2])

Submission status: Wrong Answer

Solution code:
import math
def nCm(n, m):
    return math.factorial(n) / (math.factorial(m) * (math.factorial(n - m)))
    
n = int(input())

N = [int(i) for i in input().split()]
N.sort()

N_max = N[-1]


if n % 2 == 0:
    N_mid = N[int(n/2-1)]
    print(N_max,N_mid)
else:
    N_mid1 = N[int((n-1)/2-1)]
    N_mid2 = N[int((n-1)/2)]
    
    if nCm(N_max,N_mid1) >= nCm(N_max,N_mid2):
        print(N_max,N_mid1)
    else:
        print(N_max,N_mid2)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
a.sort()
a_i = a[-1]
a_i_2 = a_i / 2.0
b = a[0]
for i in a:
    if i < a_i_2:
        b = i
    elif i != a_i:
        c = i
        break
    else:
        c = 0
        break
from scipy.misc import comb
if comb(a_i, b) > comb(a_i,c):
    print("{} {}".format(a_i, b))
else:
    print("{} {}".format(a_i, c))

Submission status: Wrong Answer

Solution code:
n=int(input())
A=list(map(int,input().split()))
x=max(A)
B=[abs(x/2-a) for a in A]
y=A[B.index(min(B))]
print(x,y)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = [0]*n
a = list(map(int, input().split()))

a.sort()
hoge = a[n-1] / 2 - a[0]
ans = 0
for i in range(n-1):
    print(abs(a[n-1] / 2 - a[i+1]))
    if abs(a[n-1] / 2 - a[i+1]) > hoge:
        ans = i
        break
    else:
        hoge = abs(a[n-1] / 2 - a[i+1])

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

Submission status: Wrong Answer

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

biggest = max(a)
base = biggest / 2

res = None
diff = 1000000000
for elem in a:
    if diff > abs(base - elem):
        diff = abs(base - elem)
        res = elem
print(biggest, res)

Submission status: Wrong Answer

Solution code:
from math import factorial
from scipy.misc import comb
n = int(input())
a = [int(i) for i in input().split()]
sa = sorted(a,reverse=True)
sb = sa[1:]
l = len(sb)
n = sa[0]
a1 = sb[l//2 - 1]
a2 = sb[l//2]
k = comb(n,a1)
j = comb(n,a2)
if k > j:
    print(n, a1)
else:
    print(n, a2)

Submission status: Wrong Answer

Solution code:
def comb(n,r):
    result=1
    for i in range(r):
        result*=(n-r+i+1)/(i+1)
    return(result)
n=int(input())
a=list(map(int,input().split()))
max_a=max(a)
mini=10**9
result=[max_a,mini]
for i in range(n):
    if mini > abs(a[i]-max(a)/2):
        
        mini=min(mini,abs(a[i]-max(a)/2))
        result[1]=a[i]
print(result[0],result[1])