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

c = max(a)
a.remove(c)
b = 0
d = c//2
for i in range(d):
    if d+1+i in a:
        b = d+i+1
        break
    elif c-(d+1+i) in a:
        b = c-(d+1+i)
        break

print(c, b)

Submission status: Wrong Answer

Solution code:
n = int(input())

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

c = max(a)
a.remove(c)
b = 0
for i in range(c//2):
    if c//2+1+i in a:
        b = c//2+i+1
        break
    elif c-(c//2+1+i) in a:
        b = c-(c//2+1+i)
        break

print(c, b)

Submission status: Wrong Answer

Solution code:
n = int(input())

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

c = max(a)
b = 0
for i in range(c//2):
    if c//2+1+i in a:
        b = c//2+i+1
        break
    elif c-(c//2+1+i) in a:
        b = c-(c//2+1+i)
        break

print(c, b)

Submission status: Wrong Answer

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

a = sorted(a)
max_a = a[-1]
max_a_harf = (max_a+1) // 2
left_med_a = a[n//2-1]
right_med_a = a[n//2]

if abs(max_a_harf - left_med_a) < abs(max_a_harf - right_med_a):
    print(max_a, left_med_a)
else:
    print(max_a, right_med_a)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    n=int(input())
    A=list(map(int,input().split()))
    A.sort()
    m=A[-1]

    from bisect import bisect_left as bisect
    i=bisect(A,m/2)
    a=A[i]
    b=A[i-1] if(i) else None

    if(a==m):
        print(m,b)
    elif(b is None):
        print(m,a)
    elif(abs(a-m/2)<abs(b<m/2)):
        print(m,a)
    else:
        print(m,b)
resolve()

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
a.sort()
import bisect
maxn = a[-1]
idx = bisect.bisect_left(a,maxn/2)
r1 = a[idx]
r2 = a[idx-1]

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


if cmb(maxn,r1) >= cmb(maxn,r2):
    print(maxn,r1)
else:
    print(maxn,r2)

Submission status: Wrong Answer

Solution code:
from sys import stdin
input = stdin.readline

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

a_max=max(a)
a_max_half=a_max/2
tmp=a[0]
for i in range(1,n):
    if abs(a[i]-a_max_half)<abs(tmp-a_max_half):
        tmp=a[i]
    # print(abs(a[i]-a_max_half))
    # print(abs(a[i-1]-a_max_half))
    # print(tmp)
print(a_max,tmp)

Submission status: Wrong Answer

Solution code:
from sys import stdin
import statistics
from math import factorial

n = int(stdin.readline().rstrip())
li = list(map(int,stdin.readline().rstrip().split()))
li.sort()

def combinations_count(n, r):
    return factorial(n) // (factorial(n - r) * factorial(r))#組み合わせ

if n % 2 == 0:
    if li[-1] ==  li[n//2]:
        me = li[0]
    else:
        if combinations_count(li[-1],li[n//2]) >= combinations_count(li[-1],li[n//2-1]):
            me = li[n//2]
        else:
            me = li[n//2-1]
else:
    me = statistics.median(li)

lin = [me,li[-1]]

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

Submission status: Wrong Answer

Solution code:
from sys import stdin
import statistics
from math import factorial

n = int(stdin.readline().rstrip())
li = list(map(int,stdin.readline().rstrip().split()))
li.sort()

if n % 2 == 0:
    if li[-1] ==  li[n//2]:
        me = li[0]
    else:
        me = li[n//2]
else:
    me = statistics.median(li)

lin = [me,li[-1]]

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

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(int(x) for x in input().split())
a.sort()

a_i = a[-1]

key_small, key_large = 0, n-1
border = a_i//2
while key_small < key_large-1:
    key = (key_small+key_large)//2
    if a[key] <= border:
        key_small = key
    else:
        key_large = key

p, q = a[key_small], a[key_large]

judge = a_i / 2
if abs(p-judge) < abs(q-judge):
    a_j = p
else:
    a_j = q

print(a_i, a_j)

Submission status: Wrong Answer

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

A.sort()
num=0
for i in range(n):
  num=max(num,abs(A[i]-A[-1]//2))
print(A[-1],num)

Submission status: Wrong Answer

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

A.sort()
for i in range(1,n):
  if (A[-1]//2)+i in A:
    print(A[-1],(A[-1]//2)+i)
    break
  elif (A[-1]//2)-i in A:
    print(A[-1],(A[-1]//2)-i)
    break

Submission status: Wrong Answer

Solution code:
from scipy.misc import comb
n=int(input())
A=list(map(int,input().split()))

A.sort()
max_,num=0,0
for i in range(int(n**0.5)+1):
  if max_<comb(A[-1],A[i]):
    max_=comb(A[-1],A[i])
    num=A[i]
print(A[-1],num)

Submission status: Wrong Answer

Solution code:
from scipy.misc import comb
n=int(input())
A=list(map(int,input().split()))

A.sort()
max_,num=0,0
for a in A:
  if max_<comb(A[-1],a):
    max_=comb(A[-1],a)
    num=a
  else:
    break
print(A[-1],num)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
m = max(a)
dis = [abs(m/2 - a[i]) for i in range(n-1)]
if a[-1] == m:
    r = a[dis.index(min(dis))]
else:
    r = a[dis.index(min(dis))+1]
print(m,r)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
m = max(a)
dis = [abs(m/2 - a[i]) for i in range(n-1)]
r = a[dis.index(min(dis))]
print(m,r)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
dis = [abs(max(a)/2 - a[i]) for i in range(n-1)]
r = a[dis.index(min(dis))]
print(max(a),r)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
a.sort()
dis = [abs(a[-1]//2 - a[i]) for i in range(n-1)]
r = a[a.index(min(a))]
print(a[-1],a[a.index(min(a))])

Submission status: Wrong Answer

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


n = int(input())
a = list(map(int,input().split()))
a.sort()
#b = list(itertools.combinations(a,2))
ans = [0,(0,0)]
#print(b)
if n > 10:
    k = (n // 2 - 5)
    l = 10
else:
    k = 0
    l = n
for i in range(l):
    tmpans = combinations_count(a[-1],a[i - k])
    if tmpans >= ans[0]:
        ans = [tmpans,(a[-1],a[i])]
        
print(ans[1][0],ans[1][1])

Submission status: Wrong Answer

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


n = int(input())
a = list(map(int,input().split()))
b = list(itertools.combinations(a,2))
ans = [0,(0,0)]
#print(b)
for i in range(len(b)):
    tmpans = combinations_count(max(b[i][0], b[i][1]),min(b[i][0], b[i][1]))
    if tmpans >= ans[0]:
        ans = [tmpans,(b[i][0], b[i][1])]
        
print(ans[1][0],ans[1][1])

Submission status: Wrong Answer

Solution code:
n=int(input())
a=sorted(list(map(int,input().split())))
m=a[n-1]
a=a[:n]
h=m/2
import bisect as bi
x=bi.bisect_left(a,h)
if a[x]-h>h-a[x-1]:
  x-=1
print(m,a[x])

Submission status: Wrong Answer

Solution code:
from operator import mul
from functools import reduce
import bisect

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

N = int(input())
A = sorted(list(map(int,input().split())))
maxA = max(A)
A.remove(maxA)
idx = bisect.bisect(A,maxA//2)
if idx == len(A): idx -= 1
print(maxA,A[idx])

Submission status: Wrong Answer

Solution code:
n = int(input())
A = list(map(int, input().split()))
maxA = max(A)
halfA = maxA // 2
tmp = 10 ** 9
r = 0
for a in A:
    half = abs(halfA - a)
    if tmp > half:
        tmp = half
        r = a

print(maxA, r)

Submission status: Wrong Answer

Solution code:
import bisect as bi

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

ai=a[-1]
jl=bi.bisect_left(a,ai/2)
jr=bi.bisect_right(a,ai/2)

if ai/2-a[jl]<=a[jr-1]-ai/2:
    print(ai,a[jl])
else:
    print(ai,a[jr-1])

Submission status: Wrong Answer

Solution code:
import bisect as bi

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

ai=a[-1]
jl=bi.bisect_left(a,ai/2)
jr=bi.bisect_right(a,ai/2)

if ai/2-a[jl]<=a[jr]-ai/2:
    print(ai,a[jl])
else:
    print(ai,a[jr])

Submission status: Wrong Answer

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

m = lst[-1]
line = m / 2
r = 10**10

for i in range(n):
    if abs(r-line) > abs(lst[i]-line):
        r = lst[i]
print(r,m)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3

import math
import bisect
import numpy as np

n = int(input().split()[0])
a_list = list(map(int, input().split()))


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


a_list = sorted(a_list)
max_comb = -float("inf")
a_list = sorted(a_list, reverse=True)
ai = a_list[0]
w_list = a_list[1:]
w_list = sorted(w_list)

# 真ん中に一番近い値を取得する
if ai % 2 == 0:
    if ai // 2 in w_list:
        aj = ai // 2
    else:
        idx = bisect.bisect_left(w_list, ai // 2)
        if idx + 1 < len(a_list):
            if abs(ai // 2 - a_list[idx + 1]) < abs(ai // 2 - a_list[idx]):
                idx = idx + 1
        aj = a_list[idx]
else:
    # 奇数の場合、候補が2つある
    target_1 = (ai - 1) // 2
    idx_1 = bisect.bisect_left(w_list, target_1)
    aj = w_list[idx_1]

    target_2 = (ai + 1) // 2
    idx_2 = bisect.bisect_left(w_list, target_2)

    if abs(a_list[idx_1] - target_1) > abs(a_list[idx_2] - target_2):
        aj = w_list[idx_2]

ans = "{} {}".format(ai, aj)
print(ans)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3

import math

n = int(input().split()[0])
a_list = list(map(int, input().split()))


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


a_list = sorted(a_list)
max_comb = -float("inf")

for i, ai in enumerate(a_list):
    for j, aj in enumerate(a_list[:i]):
        comb = C(ai, aj)
        if max_comb < comb:
            max_comb = comb
            comb_set = (ai, aj)

ans = "{} {}".format(ai, aj)
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
k = [int(i) for i in input().split()]
ans1 = max(k)
k.remove(ans1)
c = ans1
ans2 = 0
if ans1%2:
    for i in k:
        if abs(i-ans1/2) <= c:
            ans2 = i
            c = abs(i-ans1/2)
print(ans1,ans2)

Submission status: Wrong Answer

Solution code:
n = int(input())
k = [int(i) for i in input().split()]
ans1 = max(k)
k.remove(ans1)
c = ans1
ans2 = 0
if ans1%2:
    for i in k:
        if abs(i-ans1//2) < c:
            ans2 = i
            c = abs(i-ans1//2)
print(ans1,ans2)

Submission status: Wrong Answer

Solution code:
import bisect
n=int(input())
l=list(map(int,input().split()))
l.sort()
if n==2:
    print(l[1],l[0])
    exit()
m=max(l)
k=m//2
if m%2==1:
    k+=1
i=bisect.bisect_left(l,k)
if abs(l[i]-k)<=abs(l[i+1]-k):
    print(m,l[i])
else:
    print(m,l[i+1])

Submission status: Wrong Answer

Solution code:
import bisect
n=int(input())
l=list(map(int,input().split()))
l.sort()
if n==2:
    print(l[1],l[0])
    exit()
m=max(l)
k=m//2
i=bisect.bisect_left(l,k)
if abs(l[i]-k)<abs(l[i+1]-k):
    print(m,l[i])
else:
    print(m,l[i+1])

Submission status: Wrong Answer

Solution code:
import bisect
n=int(input())
l=list(map(int,input().split()))
l.sort()
if n==2:
    print(l[1],l[0])
    exit()
m=max(l)
k=m//2
if m%2==1:
    k+=1
i=bisect.bisect_left(l,k)
if abs(l[i]-k)<abs(l[i+1]-k):
    print(m,l[i])
else:
    print(m,l[i+1])

Submission status: Wrong Answer

Solution code:
n = int(input())
k = [int(i) for i in input().split()]
ans1 = max(k)
k.remove(ans1)
c = ans1
ans2 = 0
if ans1%2:
    for i in k:
        if abs(i-ans1//2) <= c:
            ans2 = i
            c = abs(i-ans1//2)
        if abs(i-ans1//2-1) <= c:
            ans2 = i
            c = abs(i-ans1//2-1)
else:
    for i in k:
        if abs(i-ans1//2-1) <= c:
            ans2 = i
            c = abs(i-ans1//2-1)
print(ans1,ans2)

Submission status: Wrong Answer

Solution code:
n = int(input())
k = [int(i) for i in input().split()]
ans1 = max(k)
k.remove(ans1)
c = ans1
ans2 = 0
if ans1%2:
    for i in k:
        if abs(i-ans1//2) < c:
            ans2 = i
            c = abs(i-ans1//2)
        if abs(i-ans1//2-1) < c:
            ans2 = i
            c = abs(i-ans1//2-1)
else:
    for i in k:
        if abs(i-ans1//2-1) < c:
            ans2 = i
            c = abs(i-ans1//2-1)
print(int(ans1),int(ans2))

Submission status: Wrong Answer

Solution code:
n = int(input())
k = [int(i) for i in input().split()]
ans1 = max(k)
k.remove(ans1)
c = ans1
ans2 = 0
if ans1%2:
    for i in k:
        if abs(i-ans1//2) < c:
            ans2 = i
            c = abs(i-ans1//2)
        if abs(i-ans1//2-1) < c:
            ans2 = i
            c = abs(i-ans1//2-1)
else:
    for i in k:
        if abs(i-ans1//2-1) < c:
            ans2 = i
            c = abs(i-ans1//2-1)
print(ans1,ans2)

Submission status: Wrong Answer

Solution code:
n = int(input())
k = [int(i) for i in input().split()]
ans1 = max(k)
k.remove(ans1)
c = ans1
ans2 = -1
if ans1%2:
    for i in k:
        if abs(i-ans1//2) < c:
            ans2 = i
            c = abs(i-ans1//2)
        if abs(i-ans1//2-1) < c:
            ans2 = i
            c = abs(i-ans1//2-1)
else:
    for i in k:
        if abs(i-ans1//2-1) < c:
            ans2 = i
            c = abs(i-ans1//2-1)
print(ans1,ans2)

Submission status: Wrong Answer

Solution code:
from math import factorial
n = int(input())
lst = list(map(int,input().split()))
lst.sort()
num = lst[-1]
ans = 0
for i in range(n):
    x = factorial(num) / factorial(lst[i]) / factorial(num-lst[i])
    if (x > ans):
        ans = x
    else:
        print(lst[i-1],num)
        exit()

Submission status: Wrong Answer

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

if n == 2:
    print(a[1], a[0])
elif abs(a[-1] / 2 - a[bisect_left(a, a[-1] / 2)]) < abs(a[-1] / 2 - a[bisect_left(a, a[-1] / 2) + 1]):
    print(a[-1], a[bisect_left(a, a[-1] / 2)])
else:
    print(a[-1], a[bisect_left(a, a[-1] / 2) + 1])

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

print(a[-1], a[bisect_left(a, a[-1] / 2)])

Submission status: Wrong Answer

Solution code:
from bisect import bisect_left

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

A.sort()
for i in reversed(range(N)):
    a = A[i]
    ia = bisect_left(A, a/2)
    a1, a2 = A[ia-1], A[ia]
    if min(a1, a-a1) > min(a2, a-a2):
        b = a1
    else:
        b = a2
    break
    
print(a, b)

Submission status: Wrong Answer

Solution code:
import math
def com(x, y):
    k = math.factorial(x)
    s = math.factorial(y)
    l = math.factorial(x - y)
    return k // (s * l)
n = int(input())
a = list(map(int, input().split()))
a.sort()
max = a[-1]
target = max / 2
min = max
for i in range(n):
    if abs(a[i] - target) < abs(min - target):
        min = a[i]
print("{} {}".format(max, min))

Submission status: Wrong Answer

Solution code:
n = int(input())
A = list(map(int,input().split()))
ans1 = max(A)
ans2 = 0
minid = 10**9+1
for a in A:
    if abs(ans1/2-a) < minid:
        minid = abs(ans1/2-a)
        ans2 = a
print(ans1, ans2)

Submission status: Wrong Answer

Solution code:
n = int(input())
A = list(map(int,input().split()))
ans1 = max(A)
ans2 = 0
minid = 10**9
for a in A:
    if abs(ans1/2-a) < minid:
        minid = abs(ans1/2-a)
        ans2 = a
print(ans1, ans2)

Submission status: Wrong Answer

Solution code:
n = int(input())
A = list(map(int,input().split()))
ans1 = max(A)
ans2 = 0
minid = 10**9
for a in A:
    if abs(ans1/2-a) < minid:
        minid = ans1/2-a
        ans2 = a
print(ans1, ans2)

Submission status: Wrong Answer

Solution code:
#094d
import math

N = int(input()) #N<10**5
a_tuple = tuple(int(e) for e in input().split())

comb_n = max(a_tuple)

comb_r = max([abs(comb_n/2 - a) for a in a_tuple])
if math.ceil(comb_r) in a_tuple:
    comb_r = math.ceil(comb_r)
elif  math.floor(comb_r) in a_tuple:
    comb_r = math.floor(comb_r)

print(comb_n,comb_r)

Submission status: Wrong Answer

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

A=sorted(A)
maxA=max(A)
limit=maxA//2

for i in range(N):
    comb=A[i]
    if(limit<A[i]):
        if(len(A)>2):
            if(abs(limit-A[i+1])<abs(limit-A[i])):
                comb=A[i+1]
        break

print(maxA,comb)

Submission status: Wrong Answer

Solution code:
import math

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

A=sorted(A)
maxA=max(A)
limit=math.ceil(maxA/2)
comb=min(A)
for i in range(N):
    if(limit<A[i]):
        break
    comb=A[i]

print(maxA,comb)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
a.sort()
max_a = a[-1]
a.pop(-1)
ans =0
d = abs(int((max_a//2+1)-a[0]))
for i in range(1,n-1):
    if abs(int((max_a//2+1)-a[i]))<d:
        d=abs(int((max_a//2+1)-a[i]))
        #print(d)
        ans=a[i]
print(max_a,ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
a.sort()
max_a = a[-1]
a.pop(-1)
ans =0
d = abs((max_a//2+1)-a[0])
for i in range(1,n-1):
    if abs((max_a//2+1)-a[i])<d:
        d=abs((max_a//2+1)-a[i])
        #print(d)
        ans=i
print(str(max_a)+' '+str(a[ans]))

Submission status: Wrong Answer

Solution code:
import sys
from bisect import *

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline

def main():
    n=int(input())
    a=list(map(int, input().split()))
    a.sort()
    m=a[-1]/2
    i=bisect(a,m)
    d0=m-a[i-1]
    d1=a[i]-m
    if d0<d1:
        print(a[-1],a[i-1])
    else:
        print(a[-1],a[i])


main()

Submission status: Wrong Answer

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

seta = sorted(list(set(a)))

resn = seta[-1]
resr = seta[0]
for sa in seta:
    sabun = abs(resn / 2 - sa)
    if sabun  == 0 or sabun == 0.5:
        resr == sa
        break
    elif sabun < abs(resn / 2 - resr):
        resr = sa

print(str(resn) + " " + str(resr))

Submission status: Wrong Answer

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

a_i_index = len(a_list) - 1
a_i = a_list[-1]
max = 0
max_j_index = None

nobori = True

tmp = a_list[0]
koeta = None
for j_index in range(n):
    if a_list[j_index] * 2 > a_i:
        koeta = j_index
        break
    else:
        tmp = j_index

comb2 = 0
if n == 2:
    print(*[a_list[0], a_list[1]])
elif koeta == 0:
    print(*[a_i, a_list[koeta]])
elif (a_list[koeta]- a_i/2) > (a_i/2 - a_list[koeta-1]):
    print(*[a_i,a_list[koeta-1]])
else:
    print(*[a_i, a_list[koeta]])

Submission status: Wrong Answer

Solution code:
n=int(input())
box=sorted(list(map(int,input().split())))
right=box.pop()
point=right//2

ans=0
left=10**5
for i in box:
    if abs(i-point)<=left:
        left=abs(i-point)
        ans=i
        if ans==point or ans==point+1:
            print(right,ans)
            exit()
print(right,ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int, input().split()))
ans=[max(A)]

k=ans[0]
n=-1
for i in range(N):
    if abs(A[i]-ans[0]/2) < k and A[i] != ans[0]:
        k=A[i]-ans[0]/2
        n=i
ans.append(A[n])
        
print(*ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int, input().split()))
ans=[]
x=max(a)
ans.append(x)
a.remove(max(a))
y=x//2+1
b=10**9
d=10**9
if max(a)%2==0:
    for i in range(n-1):
        c=abs(a[i]-y)
        if b>c:
            d=a[i]
        b=min(b,c)
    ans.append(d)
    print(*ans)

else:
    for i in range(n-1):
        c=abs(a[i]-y+0.5)
        if b>c:
            d=a[i]
        b=min(b,c)
    ans.append(d)
    print(*ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int, input().split()))
ans=[]
x=max(a)
ans.append(x)
a.remove(max(a))
y=x//2+1
b=10**9
d=10**9
for i in range(n-1):
    c=abs(a[i]-y)
    if b>c:
        d=a[i]
    b=min(b,c)
ans.append(d)
print(*ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int, input().split()))
ans=[]
x=max(a)
ans.append(x)
y=x//2+1
b=10**9
d=10**9
for i in range(n):
    c=abs(a[i]-y)
    if b>c:
        d=a[i]
    b=min(b,c)
ans.append(d)
print(*ans)

Submission status: Wrong Answer

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

maxi = max(an)
v = maxi
for a in an:
  if a == maxi:
    continue
  if abs(a-maxi/2) < abs(v-maxi/2):
    v = a
print(' '.join( map(str, [maxi, v]) ))

Submission status: Wrong Answer

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

maxi = max(an)
v = maxi
for a in an:
  if a == maxi:
    continue
  if abs(a-maxi) < abs(v-maxi):
    v = a
print(' '.join( map(str, [maxi, v]) ))

Submission status: Wrong Answer

Solution code:
from bisect import bisect_left

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

def combination(n, r): #nCrを求める
    if n - r < r:
        r = n - r
    tmp = 1
    for i in range(n - r + 1, n + 1):
        tmp *= i
    for i in range(1, r + 1):
        tmp //= i
    return tmp
# print (a)
tmp = 0
ans1 = a[0]
ans2 = a[-1]
for i in range(n):
    j = bisect_left(a, a[i]//2)
    if j == i:
        continue
    # print (j)
    t = combination(a[i], a[j])
    if tmp < t:
        ans1 = a[i]
        ans2 = a[j]
        tmp = t
    if j != n - 1 and i != j + 1:
        t = combination(a[i], a[j + 1])
        if tmp < t:
            ans1 = a[i]
            ans2 = a[j + 1]
            tmp = t

print (ans1, ans2)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [int(x) for x in input().split()]
mi = max(A)
an = 1000
b = 0
for i in range(N):
  if an>abs(mi//2-(mi-A[i])) and A[i]!=mi:
    an = abs(mi//2-(mi-A[i]))
    b = A[i]
print(mi,b)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = [int(x) for x in input().split()]
mi = max(A)
an = 0
for i in range(N):
  an = max(mi-A[i],an)
print(mi,mi-an)

Submission status: Wrong Answer

Solution code:
n = int(input())
import heapq
A = list(map(int, input().split()))
a = max(A)
b = a//2
C = []
B = []
for i in range(n):
  heapq.heappush(C, abs(A[i]-b))
c = heapq.heappop(C)
print(a)
if c+b != a and A.count(c+b) == 1:
  print(c+b)
else:
  print(c-b)

Submission status: Wrong Answer

Solution code:
n = int(input())
A = list(map(int,input().split()))
ai = max(A)
dif = list(map(lambda a:abs(ai/2-a),A))
print(ai,A[dif.index(min(dif))])

Submission status: Wrong Answer

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

x = max(a)
b1 = x//2
b2 = (x+1)//2

y = x
z = x
for i in range(len(a)):
    if a[i] != x:
        tmp = min(abs(a[i]-b1), abs(a[i]-b2))
        if tmp < y:
            z = a[i]
        y = min(tmp, y) 

ans = x*z
print(x, z)

Submission status: Wrong Answer

Solution code:
N = int(input())
aList = list(map(int,input().split()))
n = max(aList)
rc = n//2
r = aList[0]
for a in aList:
    if abs(r-rc) > abs(a-rc):
        r = a
print("{} {}".format(n,r))

Submission status: Wrong Answer

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

m = a[-1]
mid = m/2

for i in range(n-1):
    if a[i] >= mid:
        print(m, a[i] if abs(mid - a[i]) < abs(mid - a[i-1]) else a[i-1])
        break

Submission status: Wrong Answer

Solution code:
import bisect

n=int(input())
a=[0]+sorted(list(map(int,input().split())))+[10**9]

ans1=a[-2]

index=bisect.bisect_right(a,(ans1)//2)

b1=a[index-1]
b2=a[index]

if abs((ans1)/2-b1)<abs((ans1)/2-b2):ans2=b1
else:ans2=b2

print(ans1,ans2,sep=" ")

Submission status: Wrong Answer

Solution code:
import bisect

n=int(input())
a=[0]+sorted(list(map(int,input().split())))+[10**9]

ans1=a[-2]

index=bisect.bisect_right(a,(ans1)//2)

b1=a[index-1]
b2=a[index]

if abs((ans1)/2-b1)<abs((ans1)/2-b2):ans2=b1
else:ans2=b2

print(a)
print(b1,b2)
print(index)

print(ans1,ans2,sep=" ")

Submission status: Wrong Answer

Solution code:
import numpy as np
n=int(input())
a=list(map(int,input().split()))
i=max(a)
near=max(a)/2
j=a[np.abs(np.asarray(a)-near).argmin()]
print(i,j)

Submission status: Wrong Answer

Solution code:
import math
from bisect import bisect_left

def C(a,b):
    return math.factorial(a) // (math.factorial(b)*math.factorial(a-b))

def check(ans, ansC, *args):
    n = len(args)
    temp = [ansC]
    for i in range(n):
        temp.append(C(args[i][0], args[i][1]))
    ind = temp.index(max(temp))
    if ind == 0:
        return ans, ansC
    else:
        return args[ind - 1], temp[ind]

n = int(input())
a = sorted(list(map(int, input().split())))
ans, ansC = [1, 0], 1

while len(a) > 1:
    A = a.pop(-1)
    if A//2 in a:
        ans, ansC = check(ans, ansC, [A, A//2])
        break
    elif A % 2 != 0 and A//2 + 1 in a:
        ans, ansC = check(ans, ansC, [A, A//2 + 1])
        break
    elif ansC > C(A, A//2):
        break
    else:
        x = A//2
        temp = bisect_left(a, x)
        if temp == 0:
            ans, ansC = check(ans, ansC, [A, a[0]])
        elif temp == len(a):
            ans, ansC = check(ans, ansC, [A, a[-1]])
        else:
            ans, ansC = check(ans, ansC, [A, a[temp]], [A, a[temp-1]])

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

Submission status: Wrong Answer

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

def main():
    _ = int(input())
    A = list(map(int,input().split()))
    A.sort()
    a = A.pop()
    b = a
    for x in A:
        if abs(a/2-x) < abs(a/2-b):
            b = x
    print(a, b)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from math import factorial

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

a.sort()

ai=a[n-1]
a0=1
for i in range(1,a[0]+1):
    a0*=(ai-(i-1))/i

for i in range(1,n-1):
    j=a[i]
    temp=a0
    for k in range(1,a[i]-a[i-1]+1):
        temp*=(ai-(a[i-1]+k-1))/(a[i-1]+k)

    if a0>=temp:
        print(str(ai)+" "+str(a[i-1]))
        exit()
    a0=temp

print(str(ai)+" "+str(a[n-2]))

Submission status: Wrong Answer

Solution code:
from math import factorial

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

a.sort()

ai=a[n-1]

a0=0
for i in range(n-1):
    j=a[i]
    temp=factorial(ai)//(factorial(ai-j)*factorial(j))
    if a0>=temp:
        print(str(a[i-1])+" "+str(ai))
        exit()
    a0=temp

print(str(a[n-2])+" "+str(ai))

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
MAX = max(A)
r_A = MAX / 2
B = list(map(lambda a:abs(a-r_A),A))
B.sort()
r1 = int(r_A + B[0])
r2 = int(r_A - B[0])
if r1 in A:
    print(MAX, r1)
else:
    print(MAX, r2)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
MAX = max(A)
r_A = MAX / 2
B = list(map(lambda a:abs(a-r_A),A))
B.sort()
r1 = r_A + B[0]
r2 = r_A - B[0]
if r1 in B:
    print(MAX, r1)
else:
    print(MAX, r2)

Submission status: Wrong Answer

Solution code:
import math
N = int(input())
A = list(map(int,input().split()))
MAX = max(A)
r_A = MAX // 2
A = list(map(lambda a:abs(r_A-a),A))
A.sort()
r1 = r_A + A[0]
r2 = r_A - A[0]
if r1 in A:
    print(MAX, r1)
else:
    print(MAX, r2)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = sorted(list(map(int,input().split())))
max_a = max(a)
ans = [0,10**9]
for i in a[:n-1]:
  if ans[1] > (max_a/2 - i)**2:
    ans[0] = i
    ans[1] = (max_a/2 - i)**2
print(max_a,ans[0])

Submission status: Wrong Answer

Solution code:
n = int(input())
a = sorted(list(map(int,input().split())))
ans = [a[n-1],0,10**9]
for i in a[:n-1]:
  if ans[2] > (ans[0]/2 - i)**2:
    ans[1] = i
    ans[2] = (ans[0]/2 - i)**2
print(ans[0],ans[1])

Submission status: Wrong Answer

Solution code:
n = int(input())
a = sorted(list(map(int,input().split())))
ans = [a[n-1],10**9]
for i in a[:n-1]:
  if ans[1] > (ans[0]/2 - i)**2:
    ans[1] = i
print(ans[0],ans[1])

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(200000)
input = sys.stdin.readline

N, = map(int, input().split())
L = [int(v) for v in input().split()]
L.sort()

import math
# nCr
def comb(n, r):
    return math.factorial(n) // math.factorial(r) // math.factorial(n - r)

ans = 0
t = 0
for i in range(N - 1):
    a = comb(L[-1], L[i])
    if ans < a:
        ans = a
        t = i

print(L[-1], L[t])

Submission status: Wrong Answer

Solution code:
import bisect
def cmb(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 *= int(numerator[k])

    return result

def main():
    n = int(input())
    a = [int(x) for x in input().split()]
    a = sorted(a)
    left = bisect.bisect_left(a,a[n-1]/2)
    right = left-1
    
    if cmb(a[n-1],a[left]) >= cmb(a[n-1],a[right]):
        print(a[n-1],end=" ")
        print(a[left])
    else:
        print(a[n-1],end=" ")
        print(a[right])
    
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
from bisect import bisect
from math import factorial as f

def combi(n, k):
    if n < k:
        return 0
    return f(n) // f(n-k) // f(k)

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

A.sort()

max_pair = None
max_num = 0
for a in A[::-1]:
    x = bisect(A, a//2)
    # print(a, A[x])
    if combi(a, A[x]) > max_num:
        max_num = combi(a, A[x])
        max_pair = (a, A[x])
    if x+1 < N and combi(a, A[x+1]) > max_num:
        max_num = combi(a, A[x+1])
        max_pair = (a, A[x+1])

print(max_pair)

Submission status: Wrong Answer

Solution code:
import sys
from operator import mul
from functools import reduce
stdin = sys.stdin

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

n = ni()
a = na()
list.sort(a, reverse=True)
l = a[0]
ans = -10000
if n == 2:
    print(*a)
else:
    for i in range(1, n)[::-1]:
        if l - a[i] - 1 > a[i]:
            continue
        else:
            print(l, a[i])
            break