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:
from math import factorial
import numpy as np
def comb(n, r):
	return factorial(n) // factorial(r) // factorial(n-r)

def ABC094D(n, a):
	a = sorted(a)[::-1]
	Max = comb(a[0], a[1])



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

Submission status: Wrong Answer

Solution code:
from math import factorial
def comb(n, r):
	return factorial(n) // factorial(r) // factorial(n-r)
	r = min(r, n-r)
	ans = 1
	for i in range(n-r+1, n+1):
		ans *= i
	for i in range(2, r+1):
		ans //= i
	return ans

def ABC094D(n, a):
    a = sorted(a)[::-1]
    Max = 0
    for i in range(n-1):
        for j in range(i, n):
            ans = comb(a[i], a[j])
            if ans > Max:
                Max, a1, a2 = ans, a[i], a[j]
    print(a1, a2) #, Max)

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

Submission status: Wrong Answer

Solution code:
def comb(n, r):
	# return factorial(n) // factorial(r) // factorial(n-r)
	r = min(r, n-r)
	ans = 1
	for i in range(n-r+1, n+1):
		ans *= i
	for i in range(2, r+1):
		ans //= i
	return ans

def ABC094D(n, a):
    a = sorted(a)[::-1]
    Max = 0
    for i in range(n-1):
        for j in range(i, n):
            ans = comb(a[i], a[j])
            if ans > Max:
                Max, a1, a2 = ans, a[i], a[j]
    print(a1, a2, Max)

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

Submission status: Wrong Answer

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

from bisect import bisect_right
if A[-1] % 2 == 0:
    i = bisect_right(A, A[-1]//2)
else:
    i = bisect_right(A, (A[-1]+1)//2)
if A[i-1]-N//2 <= A[i]-N//2:
    r = A[i-1]
else:
    r = A[i]
print(A[-1], r)

Submission status: Wrong Answer

Solution code:
N, *A = map(int, open(0).read().split())

print(max(A), min(A))

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
a.sort()
b=[]
M=a[n-1]
for i in range(n//2,n-1):
    b.append(M-a[i])
c=a+b
c.sort()

import bisect
index=bisect.bisect_right(c,M//2)-1

if c[index] in a:
    print(M,c[index])
else:
    print(M,M-c[index])

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,(input().split())))
M = max(a)
nim = 10**9
for i in range(n):
    d = abs(M - a[i]*2)
    if d < nim:
        nim = d
        nimi = i
print(M,a[nimi])

Submission status: Wrong Answer

Solution code:
from bisect import bisect_left

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

maxi=a[-1]
tmp=maxi/2
idx=bisect_left(a,tmp)
if idx==n-1:
  idx -=1

if a[idx]-tmp>a[idx-1]-tmp:
  idx -=1 
  
print(maxi,a[idx])

Submission status: Wrong Answer

Solution code:
from bisect import bisect_left

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

maxi=a[-1]
tmp=maxi/2
idx=bisect_left(a,tmp)
if idx==n-1:
  idx -=1

print(maxi,a[idx])

Submission status: Wrong Answer

Solution code:
from bisect import bisect_left

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

maxi=a[-1]
tmp=maxi//2
idx=bisect_left(a,tmp)
if idx==n-1:
  idx -=1

print(maxi,a[idx])

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
a.sort()
i=max(a)
if i%2==0:
    r=int(i/2)
else:
    r=int((i+1)/2)
nl=[x for x in a if x>=r]
if nl==[] or nl==[i]:
    print(i,a[n-2])
else:
    print(i,nl[0])

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
i=max(a)
if i%2==0:
    r=int(i/2)
else:
    r=int((i+1)/2)
if n==2:
    print(max(a),min(a))
    exit()
if a.count(r)>0:
    print(i,r)
    exit()
a.append(r)
a.sort()
whe=a.index(r)
if whe==0:
    print(i,a[1])
    exit()
elif whe==n-1:
    print(i,a[n-2])
    exit()
hi=a[whe+1]
lo=a[whe-1]
if abs(hi-r)>=abs(lo-r):
    print(i,hi)
else:
    print(i,lo)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
i=max(a)
if i%2==0:
    r=int(i/2)
else:
    r=int((i+1)/2)
if n==2:
    print(max(a),min(a))
    exit()
if a.count(r)>0:
    print(i,r)
    exit()
a.append(r)
a.sort()
whe=a.index(r)
hi=a[whe+1]
lo=a[whe-1]
if abs(hi-r)>=abs(lo-r):
    print(i,hi)
else:
    print(i,lo)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
i=max(a)
r=int((i+1)/2)
if n==2:
    print(max(a),min(a))
    exit()
if a.count(r)>0:
    print(i,r)
    exit()
a.append(r)
a.sort()
whe=a.index(r)
hi=a[whe+1]
lo=a[whe-1]
if abs(hi-r)>=abs(lo-r):
    print(i,hi)
else:
    print(i,lo)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
a.sort()
i=max(a)
r=int((i+1)/2)
nl=[x for x in a if x>=r]
if nl==[] or nl==[i]:
    print(i,a[n-2])
else:
    print(i,nl[0])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
from bisect import bisect_left,bisect_right
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    n=int(input())
    a=list(map(int,input().split()))
    a.sort()
    print(a[-1],a[bisect_left(a,a[-1]//2)] if a[bisect_left(a,a[-1]//2)]!=a[-1] else a[bisect_left(a,a[-1]//2)-1])
    

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
from bisect import bisect_left,bisect_right
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    n=int(input())
    a=list(map(int,input().split()))
    a.sort()
    print(a[-1],a[bisect_left(a,a[-1]//2)])
    

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
import bisect

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    A = sorted(list(map(int, input().split())))
    if n == 2:
        print(*A[::-1])
        exit()

    idx = bisect.bisect_left(A, A[-1] // 2)
    if abs(A[-1] - A[idx]) > abs(A[-1] - A[idx - 1]):
        idx -= 1

    print(A[-1], A[idx])


if __name__ == '__main__':
    resolve()

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int, input().split()))
if N == 2:
    print(max(a), min(a))
    quit()
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under
a.sort()
from bisect import bisect_left
#for i in range(N):
cur = a[N - 1] // 2
s = bisect_left(a, cur)
ans = [a[N - 1], a[s]]
if cmb(a[N - 1], a[s]) < cmb(a[N - 1], a[s - 1]):
    ans[1] = a[s - 1]
print(ans)

Submission status: Wrong Answer

Solution code:
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

def main():
    n = ni()
    a = nl()

    a.sort()
    ans = [a[-1]]

    left = bisect_left(a, max(a)/2)
    right = bisect_right(a, max(a)/2)
    
    if abs(max(a)/2 - a[left]) <= abs(max(a)/2 - a[right]):
        ans.append(a[left])
    else:
        ans.append(a[right])

    if ans[0] == ans[1]:
        ans[1] = 0

    print(*ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

def main():
    n = ni()
    a = nl()

    a.sort()
    ans = [a[-1]]

    left = bisect_left(a, max(a)/2)
    right = bisect_right(a, max(a)/2)
    if abs(max(a)/2 - a[left]) <= abs(max(a)/2 - a[right]):
        ans.append(a[left])
    else:
        ans.append(a[right])

    print(*ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n = int(input())
a  = list(map(int,input().split()))
N = max(a)
res = 10**10
k = []
for i in range(n):
    
    if abs(a[i]-N/2) <= res:
        res = abs(a[i] -N/2)
        k.append(a[i])
k.sort()
print(N,k[0])

Submission status: Wrong Answer

Solution code:
n = int(input())
a  = list(map(int,input().split()))
N = max(a)
res = 10**10
k = []
for i in range(n):
    
    if abs(a[i]-N//2) < res:
        res = abs(a[i] -N//2)
        k.append(a[i])
k.sort()
print(N,k[0])

Submission status: Wrong Answer

Solution code:
n = int(input())
a  = list(map(int,input().split()))
N = max(a)
res = 10**10
K = 0
for i in range(n):
    
    if abs(a[i]-N//2) < res:
        res = abs(a[i] -N//2)
        K = i
print(N,a[K])

Submission status: Wrong Answer

Solution code:
n = int(input())
a  = list(map(int,input().split()))
N = max(a)
res = 10**9
K = 0
for i in range(n):
    
    if abs(a[i]-N/2) < res:
        res = abs(a[i] -N/2)
        K = i
print(N,a[K])

Submission status: Wrong Answer

Solution code:
def main():
  n = int(input())
  a = list(map(int, input().split()))
  a.sort()
  
  r = 0
  c = n / 2
  for i in range(n-1):
    if abs(c-r) > abs(c-a[i]):
      r = a[i]
  ans = "{} {}".format(a[-1], r)
  print(ans)

  
if __name__ == "__main__":
  main()

Submission status: Wrong Answer

Solution code:
from bisect import bisect_left
N = int(input())
A = list(map(int,input().split()))
A.sort()
n = A.pop()
index = bisect_left(A, n//2+1)
if index == 0:
    r = A[0]
elif index == N-1:
    r = A[N-2]
else:
    if abs(n//2+1-A[index]) <= abs(n//2+1-A[index-1]):
        r = A[index]
    else:
        r = A[index - 1]
print(*[n,r])

Submission status: Wrong Answer

Solution code:
from bisect import bisect_left
N = int(input())
A = list(map(int,input().split()))
A.sort()
n = A.pop()
index = bisect_left(A, n//2+1)
if index == 0:
    r = A[0]
elif index == N-1:
    r = A[N-2]
else:
    if abs(n//2+1-A[index]) <= abs(n//2+2-A[index]):
        r = A[index]
    else:
        r = A[index - 1]
print(*[n,r])

Submission status: Wrong Answer

Solution code:
from bisect import bisect_left
N = int(input())
A = list(map(int,input().split()))
A.sort()
n = A.pop()
index = bisect_left(A, n//2+1)
if index == 0:
    r = A[0]
elif index == N-1:
    r = A[N-2]
else:
    if abs(n//2+1-index) <= abs(n//2+2-index):
        r = A[index]
    else:
        r = A[index - 1]
print(*[n,r])

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
ans1 = max(a)
diff = min(ans1//2, ans1//2 + 1)
ans2 = ans1
for x in a:
  d = min(abs(ans1//2 - x), abs(ans1//2 + 1 - x))
  if d < diff:
    diff = d
    ans2 = x
print('{} {}'.format(ans1, ans2))

Submission status: Wrong Answer

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

max_n = max(a)

tmp = max_n/2
check = 10**9+7

for i in range(n):
    res = abs(a[i] - tmp)
    if check >= tmp:
        check = tmp
        ans_r = a[i]
        
print(max_n,ans_r)

Submission status: Wrong Answer

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

max_n = max(a)

tmp = max_n//2
check = 10**9+7

for i in range(n):
    res = abs(a[i] - tmp)
    if check >= tmp:
        check = tmp
        ans_r = a[i]
        
print(max_n,ans_r)

Submission status: Wrong Answer

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

max_n = max(a)

tmp = max_n//2
check = 10**9+7

for i in range(n):
    res = a[i] - tmp
    if check > tmp:
        check = tmp
        ans_r = a[i]
        
print(max_n,ans_r)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]
import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from itertools import accumulate #list(accumulate(A))

N = ii()
A = sorted(li())
half = A[-1]//2

ind = bisect.bisect_left(A, half)

if A[ind]!=half:
    if ind > 0 and half - A[ind-1] <= A[ind] - half:
        ind -= 1

print(A[-1], A[ind])

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]
import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from itertools import accumulate #list(accumulate(A))

N = ii()
A = sorted(li())
half = A[-1]//2

ind = bisect.bisect_left(A, half)

if A[ind]!=half:
    if ind > 0 and half - A[ind-1] < A[ind] - half:
        ind -= 1

print(A[-1], A[ind])

Submission status: Wrong Answer

Solution code:
import bisect
n,*a=map(int,open(0).read().split())
a=sorted(a)
m=a[-1]
l=bisect.bisect_left(a,(m+1)//2)
r=bisect.bisect_right(a,(m+1)//2)
if abs(2*a[l]-1-m)<=abs(2*a[r]-1-m):
  k=a[l]
else:
  k=a[r]
if len(a)==2:
  k=a[0]
print(m,k)

Submission status: Wrong Answer

Solution code:
from scipy.misc import comb

url = "https://atcoder.jp//contests/abc094/tasks/arc095_b"

def main():
    input()
    t = list(map(int, input().split()))
    combs = {}
    for i in range(-1, -2, -1):
        for j in range(i, len(t)):
            tmp = sorted([t[i], t[j]], reverse=True)
            combs[comb(tmp[0], tmp[1], exact=True)] = tmp[::]
    key = max(combs.keys())
    print(' '.join([str(v) for v in combs[key]]))

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from math import factorial
N = int(input())
A = list(map(int,input().split()))
t, j = float("INF"), -1
max_A = max(A)
for i in range(N):
  if abs(max_A//2 - A[i]) < t:
    t = abs(max_A//2 - A[i])
    j = i
print(max(A), A[j])

Submission status: Wrong Answer

Solution code:
from math import factorial
N = int(input())
A = list(map(int,input().split()))
t, j = float("INF"), -1
for i in range(N):
  if abs(max(A)//2 - A[i]) < t:
    t = abs(max(A)//2 - A[i])
    j = i
print(max(A), A[j])

Submission status: Wrong Answer

Solution code:
from math import factorial
N = int(input())
A = list(map(int,input().split()))
A.sort(reverse=True)
print(A[0], A[N//2])

Submission status: Wrong Answer

Solution code:
import sys
IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))
from bisect import bisect_left

def main():
    n = II()
    aa = MII()
    if n == 2: print(*aa); exit(0)
    aa.sort()
    ans_n = aa[-1]
    m = ans_n/2
    idx = bisect_left(aa, m)
    ans_r = aa[idx]
    if abs(aa[idx]-m) > abs(aa[idx+1]-m):
        ans_r = aa[idx+1]
    print(ans_n, ans_r, end= ' ')

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))
from bisect import bisect_left
def main():
    n = II()
    aa = MII()
    if n == 2: print(*aa); exit(0)
    aa.sort()
    maxa = aa[-1]
    m = maxa/2
    m_idx = bisect_left(aa, m)
    a = aa[m_idx]
    b = aa[m_idx-1]
    if m-a <= m-b:
        print('{} {}'.format(maxa, a))
    else:
        print('{} {}'.format(maxa, b))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))
from bisect import bisect_left
MOD=10**9
def mod_cmb(n, r, mod):
    x = 1
    y = n
    for i in range(2,r+1):
        x *= i
        x %= mod
        y *= n-i+1
        y %= mod
    return y * pow(x, mod-2, mod) % mod

def main():
    n = II()
    aa = MII()
    if n == 2: print(*aa); exit(0)
    aa.sort()
    maxa = aa[-1]
    m = maxa//2
    m_idx = bisect_left(aa, m)
    a = aa[m_idx]
    b = aa[m_idx-1]
    if m-a <= m-b:
        print('{} {}'.format(maxa, a))
    else:
        print('{} {}'.format(maxa, b))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))
from bisect import bisect_left
MOD=10**9
def mod_cmb(n, r, mod):
    x = 1
    y = n
    for i in range(2,r+1):
        x *= i
        x %= mod
        y *= n-i+1
        y %= mod
    return y * pow(x, mod-2, mod) % mod

def main():
    n = II()
    aa = MII()
    if n == 2: print(*aa); exit(0)
    aa.sort()
    maxa = aa[-1]
    m = maxa//2
    m_idx = bisect_left(aa, m)
    a = aa[m_idx]
    b = aa[m_idx-1]
    if m-a < m-b:
        print('{} {}'.format(maxa, a))
    else:
        print('{} {}'.format(maxa, b))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n = int(input())
a = sorted(list(map(int,input().split())))
x = a.pop()
y = a[0]
m = abs(x/2 - a[0])
for i in range(1,n-1):
    if abs(x/2-a[i]) < m:
        y = a[i]
print(x,y)

Submission status: Wrong Answer

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

n = max(A)

A_sorted = sorted(A)

max_nCr = 0
r = 0

import bisect

index = bisect.bisect_left(A_sorted, n/2)

from operator import mul
from functools import reduce

def cmb(n, r):
    r = min(n - r, r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1, r + 1))
    return over // under

# print(A_sorted[index], A_sorted[index-1:index+1])
min_diff = float('inf')
for a in A_sorted[index-1:index+1]:
    if min_diff > abs(n/2 - a) and a != n:
        r = a

print(n, r)

Submission status: Wrong Answer

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

n = max(A)

A_sorted = sorted(A)

max_nCr = 0
r = 0

import bisect

index = bisect.bisect_left(A_sorted, n//2)

from operator import mul
from functools import reduce

def cmb(n, r):
    r = min(n - r, r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1, r + 1))
    return over // under

# print(A_sorted[index], A_sorted[index-1:index+1])
min_diff = float('inf')
for a in A_sorted[index-1:index+1]:
    if min_diff > abs(n//2 - a) and a != n:
        r = a

print(n, r)

Submission status: Wrong Answer

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

n = max(A)

A_sorted = sorted(A)

max_nCr = 0
r = 0

import bisect

index = bisect.bisect_left(A_sorted, n//2)

from operator import mul
from functools import reduce

def cmb(n, r):
    r = min(n - r, r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1, r + 1))
    return over // under

# print(A_sorted[index], A_sorted[index-1:index+1])
min_diff = float('inf')
for a in A_sorted[index-1:index+1]:
    if min_diff > abs(n//2 - a):
        r = a

print(n, r)

Submission status: Wrong Answer

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

n = max(A)

A_sorted = sorted(A)

max_nCr = 0
r = 0

import bisect

index = bisect.bisect_left(A_sorted, n//2)

from operator import mul
from functools import reduce

def cmb(n, r):
    r = min(n - r, r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1, r + 1))
    return over // under

# print(A_sorted[index], A_sorted[index-1:index+1])
# for a in A_sorted[index-1:index+1]:
#     nCr = cmb(n, a)
#     if max_nCr < nCr:
#         r = a
#         max_nCr = nCr
#     elif max_nCr >= nCr:
#         break

print(n, A_sorted[index])

Submission status: Wrong Answer

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

from bisect import bisect_left
ans_n = a[-1]

p = bisect_left(a, (ans_n+1)//2)
ans_r = a[p]
if abs(a[p] - ans_n/2) > abs(a[p-1] - ans_n/2):
  ans_r = a[p-1]

print(ans_n, ans_r)

Submission status: Wrong Answer

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

from operator import mul
from functools import reduce

def comb(n, r):
  r = min(r, n-r)
  numer = reduce(mul, range(n, n-r, -1), 1)
  denom = reduce(mul, range(1, r+1), 1)
  return numer // denom

from bisect import bisect_left
n = a[-1]
p = bisect_left(a, n//2) - 1

ans_r = -1
comb_max = 0
for i in range(p, n):
  c = comb(n, a[i])
  if c > comb_max:
    comb_max = c
    ans_r = a[i]
  else:
    break

print(n, ans_r)

Submission status: Wrong Answer

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

b=len(a)

r=b
l=0
while r-l>1:
  mid=(r+l)//2
  if a[mid]<=a[-1]//2:
    l=mid
  else:
    r=mid

print(a[-1],a[l])

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())
    a = list(map(int, input().split()))
    ma = max(a)
    ma2 = ma/2
    a.remove(ma)
    ans = 0
    diff = 10*10
    for i in a:
        if diff > abs(ma2-i):
            ans = i
            diff = abs(ma2-i)
    print(ma, ans)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())
    a = list(map(int, input().split()))
    ma = max(a)
    ma2 = ma/2
    a.remove(ma)
    ans = 0
    for i in a:
        if ans < abs(ma2-i):
            ans = i
    print(ma, ans)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import bisect

n = int(input())
a = list(map(int, input().split()))
a.sort()
M = max(a)
m = M // 2

left = bisect.bisect_left(a, m)
right = bisect.bisect_right(a, m)

if abs(m - a[left]) < abs(m - a[right]):
    print(M, a[left])
else:
    print(M, a[right])

Submission status: Wrong Answer

Solution code:
import bisect

n = int(input())
a = list(map(int, input().split()))
a.sort()
M = max(a)
m = M // 2

left = bisect.bisect_left(a, m)
right = bisect.bisect_right(a, m)

if abs(m - left) < abs(m - right):
    print(M, a[left])
else:
    print(M, a[right])

Submission status: Wrong Answer

Solution code:
N = int(input())
A = sorted(list(map(int, input().split())))
ai = max(A)
ai_idx = A.index(ai)
half_maxA = ai // 2 + 1
for idx, a in enumerate(A):
    if ai_idx == idx:
        continue
    if idx == 0:
        aj = a
    else:
        if abs(a - half_maxA) < abs(aj - half_maxA):
            aj = a
print(ai, aj)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = sorted(list(map(int, input().split())))
ai = max(A)
half_maxA = ai // 2 + 1
for idx, a in enumerate(A):
    if idx == 0:
        aj = a
    else:
        if abs(a - half_maxA) < abs(aj - half_maxA):
            aj = a
print(ai, aj)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = sorted(list(map(int, input().split())))
ai = max(A)
half_maxA = ai // 2
for idx, a in enumerate(A):
    if idx == 0:
        aj = a
    else:
        if abs(a - half_maxA) < abs(aj - half_maxA):
            aj = a
print(ai, aj)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,*a=map(int,open(0).read().split())
a.sort()
b=a[-1]
c=a[0]
d=b/2-c
for i in a:
    if d>abs(b/2-i):
        c=i
        d=abs(b/2-i)
print(c,b)

Submission status: Wrong Answer

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

b=max(a)
d=b/2

c=abs(d-a[0])
#print(c)
ans=a[0]
for i in a:
  #print(abs(i-d))
  if abs(i-d)<c:
    ans=i
    c=abs(i-d)
    
print(b,end=" ")
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from bisect import bisect_right
n = int(input())
A = sorted(list(map(int, input().split())))
p = A[-1]
i = bisect_right(A[:-1], p/2)
q = A[i] if abs(A[i-1]-p/2) <= abs(A[i]-p/2) else A[i]
print(p, q)

Submission status: Wrong Answer

Solution code:
from bisect import bisect_left
n = int(input())
A = sorted(list(map(int, input().split())))
p = A[-1]
i = bisect_left(A, p/2)
q = A[i] if abs(A[i-1]-p/2) <= abs(A[i]-p/2) else A[i]
print(p, q)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
from bisect import bisect_right
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=False)

top = A[-1]
half = top // 2
idx = bisect_right(A, half)
if idx == N-1:
    print(top, A[idx-1])
else:
    print(top, A[idx])

Submission status: Wrong Answer

Solution code:
n = int(input())

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

A = list(sorted(A))

a = A[-1]
b = A[n//2]
# print(a, b)
if n == 2:
    print(a, A[0])
else:
    print(a, A[n//2])

Submission status: Wrong Answer

Solution code:
from bisect import bisect_left as bl
from bisect import bisect_right as br

def main():
    N = int(input())
    A = list(map(int,input().split()))
    A.sort()
    M = A[-1]//2
    k = bl(A,M)
    l = br(A,M)
    if M in A:
        print(*[A[-1],M])
        exit()
    if k == N-1:
        ans = [A[-1],A[k-1]]
        print(*ans)
        exit()
    if l == N-1:
        ans = [A[-1],A[l-1]]
        print(*ans)
        exit()
    if N == 2:
        print(*reversed(A))
        exit()
    if abs(A[l]-M) < abs(M-A[k]):
        ans = [A[-1],A[l]]
    else:
        ans = [A[-1],A[k]]
    
    print(*ans)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
from bisect import bisect_left as bl
from bisect import bisect_right as br

def main():
    N = int(input())
    A = list(map(int,input().split()))
    A.sort()
    M = A[-1]//2
    k = bl(A,M)
    l = br(A,M)
    if k == N-1:
        ans = [A[-1],A[k-1]]
        print(*ans)
        exit()
    if l == N-1:
        ans = [A[-1],A[l-1]]
        print(*ans)
        exit()
    if N == 2:
        print(*reversed(A))
        exit()
    if abs(A[l]-M) < abs(M-A[k]):
        ans = [A[-1],A[l]]
    else:
        ans = [A[-1],A[k]]
    
    print(*ans)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
from bisect import bisect_left as bl
from bisect import bisect_right as br

def main():
    N = int(input())
    A = list(map(int,input().split()))
    A.sort()
    M = A[-1]//2
    k = bl(A,M)
    l = br(A,M)
    if k == N-1:
        ans = [A[-1],A[k-1]]
        print(*ans)
        exit()
    if N == 2:
        print(*reversed(A))
        exit()
    if abs(A[l]-M) < abs(M-A[k]):
        ans = [A[-1],A[l]]
    else:
        ans = [A[-1],A[k]]
    
    print(*ans)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
from bisect import bisect_left as bl
from bisect import bisect_right as br

def main():
    N = int(input())
    A = list(map(int,input().split()))
    A.sort()
    M = A[-1]//2
    k = bl(A,M)
    l = br(A,M)
    if abs(A[l]-M) < abs(M-A[k]):
        ans = [A[-1],A[l]]
    else:
        ans = [A[-1],A[k]]
    
    print(*ans)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
from bisect import bisect_left as bl
from bisect import bisect_right as br

def main():
    N = int(input())
    A = list(map(int,input().split()))
    A.sort()
    M = A[-1]//2
    k = bl(A,M)
    l = br(A,M)
    if abs(A[l]-M) < abs(M-A[k]):
        ans = [A[-1],A[l]]
    elif abs(A[l]-M) == abs(M-A[k]):
        if A[l] < M:
            ans = [A[-1],A[k]]
        else:
            ans = [A[-1],A[l]]
    else:
        ans = [A[-1],A[k]]
    
    print(*ans)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
from bisect import bisect_left as bl
from bisect import bisect_right as br

def main():
    N = int(input())
    A = list(map(int,input().split()))
    A.sort()
    M = A[-1]//2
    k = bl(A,M)
    l = br(A,M)
    if abs(A[l]-M) < abs(M-A[k]):
        ans = [A[-1],A[l]]
    elif abs(A[l]-M) == abs(M-A[k]):
        if A[l] < M:
            ans = [A[-1],A[k]]
        else:
            ans = [A[-1],A[k]]
    else:
        ans = [A[-1],A[k]]
    
    print(*ans)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
from bisect import bisect_left as bl
from bisect import bisect_right as br

def main():
    N = int(input())
    A = list(map(int,input().split()))
    A.sort()
    M = A[-1]//2
    k = bl(A,M)
    l = br(A,M)
    if abs(A[l]-M) > abs(M-A[k]):
        ans = [A[-1],A[l]]
    elif abs(A[l]-M) == abs(M-A[k]):
        if A[l] < M:
            ans = [A[-1],A[k]]
        else:
            ans = [A[-1],A[l]]
    else:
        ans = [A[-1],A[k]]
    
    print(*ans)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
from bisect import bisect_left as bl
from bisect import bisect_right as br
def comb(n,k):
    n1, k = n+1, min(k, n-k)
    numer = denom = 1
    for i in range(1,k+1):
        numer = numer*(n1-i)
        denom = denom*i
    return numer//denom
def main():
    N = int(input())
    A = list(map(int,input().split()))
    A.sort()
    M = A[-1]//2
    k = bl(A,M)
    l = br(A,M)
    if abs(A[l]-M) > abs(M-A[k]):
        ans = [A[-1],A[l]]
    else:
        ans = [A[-1],A[k]]
    
    print(*ans)

if __name__ == "__main__":
    main()