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 bisect import bisect_left
N = int(input())
L = list(map(int,input().split()))
L.sort()
n = L[-1]
if n//2 in L:
  print(n, n//2)
else:
  b = bisect_left(L,n//2)
  if N>b+1 and abs(b - n//2) > abs(L[b+1] - n//2):
    print(n,L[b+1])
  else:
    print(n,L[b])

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
comba = max(a)
ref = 10**10

for i in a:
    temp = abs(i - comba/2)
    if ref > i:
        if comba > i:
            ref = temp
            combb = i

print(comba, combb)

Submission status: Wrong Answer

Solution code:
import bisect
n=int(input())
a=[int(x) for x in input().split()]
a.sort()

ma=max(a)
mi=float('inf')
ans=0
for i in range(n):
  sa=ma-a[i]
  if abs(a[i]-sa)<=mi and ma!=a[i]:
    mi=sa
    ans=a[i]

print(ma,ans)

Submission status: Wrong Answer

Solution code:
import bisect
n=int(input())
a=[int(x) for x in input().split()]
a.sort()

ma=max(a)
mi=float('inf')
for i in range(n):
  now=ma-a[i]
  sa=abs(now-a[i])
  if sa<=mi:
    mi=a[i]


print(ma,mi)

Submission status: Wrong Answer

Solution code:
import bisect
n=int(input())
a=[int(x) for x in input().split()]
a.sort()

ma=max(a)
mi=float('inf')
for i in range(n):
  now=ma-a[i]
  sa=abs(now-a[i])
  if sa<mi:
    mi=a[i]


print(ma,mi)

Submission status: Wrong Answer

Solution code:
def main():
    import sys
    input = sys.stdin.readline
    
    N = int(input())
    A = set(map(int,input().split()))
    A = sorted(list(A))

    import bisect

    ans = A[-1]//2
    b = bisect.bisect_left(A,ans)

    if abs(ans-A[b])<abs(ans-A[max(0,b-1)]):
        print(A[-1],A[b])
    else:
        print(A[-1],A[b-1])

if __name__=='__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    import sys
    input = sys.stdin.readline
    
    N = int(input())
    A = set(map(int,input().split()))
    A = sorted(list(A))

    import bisect

    ans = A[-1]//2
    b = bisect.bisect_left(A,ans)

    if abs(ans-A[b])<abs(A[max(0,b-1)]):
        print(A[-1],A[b])
    else:
        print(A[-1],A[b-1])

if __name__=='__main__':
    main()

Submission status: Wrong Answer

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

max_val = a.pop()

max_dif = 10 * 100
ret = 0

for item in a:
    dif = abs(max_val - item * 2)
    if max_dif > dif:
        ret = item
        max_dif = dif

print(max_val, ret)

Submission status: Wrong Answer

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

max_val = a[-1]

max_dif = 10 * 100
ret = 0

for item in a[:-1]:
    dif = abs(max_val - item * 2)
    if max_dif > dif:
        ret = item
        max_dif = dif

print(max_val, ret)

Submission status: Wrong Answer

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

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

mdif = 10 * 100
ret = 0

for item in a[:-1]:
    dif = abs(mid - item)
    if mdif > dif:
        ret = item
        mdif = dif

print(mval, ret)

Submission status: Wrong Answer

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

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

mdif = 10 * 100
ret = 0

for item in a:
    dif = abs(mid - item)
    if mdif > dif:
        ret = item
        mdif = dif

print(mval, ret)

Submission status: Wrong Answer

Solution code:
from bisect import *
n = int(input())
a = list(map(int,input().split()))
a = sorted(a)
ans = a[-1]//2
b = bisect_left(a,ans)
if abs(ans-a[b]) <= abs(ans-a[b-1]):
  print(a[-1],a[b])
else:
  print(a[-1],a[b-1])

Submission status: Wrong Answer

Solution code:
from bisect import *
n = int(input())
a = list(map(int,input().split()))
a = sorted(a)
ans = a[-1]//2
b = bisect_left(a,ans)
if abs(ans-a[b]) < abs(ans-a[b-1]):
  print(a[-1],a[b])
else:
  print(a[-1],a[b-1])

Submission status: Wrong Answer

Solution code:
from bisect import *
n = int(input())
a = list(map(int,input().split()))
a = sorted(a)
a = list(set(a))
ans = a[-1]//2
b = bisect_left(a,ans)
if abs(ans-a[b]) <= abs(ans-a[b-1]):
  print(a[-1],a[b])
else:
  print(a[-1],a[b-1])

Submission status: Wrong Answer

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

a = sorted(a)
a = list(set(a))
ans = a[-1]//2
b = bisect_left(a,ans)
print(a[-1],a[b])

Submission status: Wrong Answer

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

a = sorted(a)
ans_num = a[-1]//2
b = bisect_left(a,ans_num)

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

Submission status: Wrong Answer

Solution code:
mod = 10**9 + 7
def comb(n,r,mod):
	a=1
	b=1
	r = min(r,n-r)
	for i in range(r):
		a = a*(n-i)%mod
		b = b*(i+1)%mod
	return a*pow(b,mod-2,mod)%mod
 
from bisect import *
n = int(input())
a = list(map(int,input().split()))

a = sorted(a)
comb_num = 0
ans_num = a[-1]//2
b = bisect_left(a,ans_num)
last = min(n-1,b+1)
for i in range(b-1,last):
  c = comb(a[-1],a[i],mod)
  comb_num = max(comb_num,c)
  if comb_num == c:
    j = i
print(a[-1],a[j])

Submission status: Wrong Answer

Solution code:
import bisect
n=int(input())
a=sorted(list(map(int,input().split())))
M=a[-1]
del a[-1]
ind=bisect.bisect_left(a,-(-M//2))
if ind==n-1:
    print(M,a[n-2])
elif ind==0:
    print(M,a[0])
else:
    if M/2-a[ind]<=M/2-a[ind-1]:
        print(M,a[ind])
    else:
        print(M,a[ind-1])

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
a.sort()
res = 0
tmp = 10000000
for i in range(n):
  if (a[i] - a[-1]/2)**2 < tmp:
    tmp = (a[i] - a[-1]/2)**2
    res = a[i]
print(a[-1],res)

Submission status: Wrong Answer

Solution code:
n = int(input())
L = sorted(list(map(int,input().split())))
if n%2 == 0:
    max1 = max(L)
    p = max1//2
    ans = 10**10
    for i in range(n-1):
        ans = min(ans,max(L[i]-p,0))

elif n%2 == 1:
    max1 = max(L)
    p,q = max1//2,max1//2+1
    ans = 10**10
    for i in range(n-1):
        ans = min(ans,min(max(L[i]-p,0),max(L[i]-q,0)))

print(L[-1],ans+p)

Submission status: Wrong Answer

Solution code:
#最大値とその半分
#コーナー分からない
n= int(input())
a = list(map(int, input().split( )))
a_ = [(a[i],i) for i in range(n)]
a_.sort()
a_mx = a_[-1][0]
a_md = a_mx/2

import bisect
ans = 0
i = bisect.bisect_left(a_,(a_md,0))
j = bisect.bisect_right(a_,(a_md,0))
if abs(a_[i][0]-a_md)>abs(a_[j][0]-a_md):###
    ans = a_[j][0]
    if abs(a_[j][0]-a_md)>abs(a_[j+1][0]-a_md):###
        ans = a_[j+1][0]
else:
    ans = a_[i][0]

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

Submission status: Wrong Answer

Solution code:
#最大値とその半分
#コーナー分からない
n= int(input())
a = list(map(int, input().split( )))
a_ = [(a[i],i) for i in range(n)]
a_.sort()
a_mx = a_[-1][0]
a_md = a_mx/2

import bisect
ans = 0
i = bisect.bisect_left(a_,(a_md,0))
j = bisect.bisect_right(a_,(a_md,0))
if abs(a_[i][0]-a_md)>abs(a_[j][0]-a_md):###
    ans = a_[j][0]
else:
    ans = a_[i][0]

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

Submission status: Wrong Answer

Solution code:
#最大値とその半分
#コーナー分からない
n= int(input())
a = list(map(int, input().split( )))
a_ = [(a[i],i) for i in range(n)]
a_.sort()
a_mx = a_[-1][0]
a_md = a_mx/2

import bisect
ans = 0
i = bisect.bisect_left(a_,(a_md,0))
j = bisect.bisect_right(a_,(a_md,0))
if abs(a_[i][0]-a_md)>(a_[j][0]-a_md):
    ans = a_[j][0]
else:
    ans = a_[i][0]

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

Submission status: Wrong Answer

Solution code:
N, = map(int, input().split())
As = list(map(int, input().split()))
am = max(As)
bm = 0
for i, a in enumerate(As):
    if min(am-a, a) > bm:
        bm = a
print(am, bm)

Submission status: Wrong Answer

Solution code:
N, = map(int, input().split())
As = list(map(int, input().split()))
am = 0
for i, a in enumerate(As):
    if a > am:
        am = a
bm = 0
for i, a in enumerate(As):
    if min(am-a, a) > bm:
        bm = a
print(am, bm)

Submission status: Wrong Answer

Solution code:
import bisect
N = int(input())
A = list(map(int, input().split()))
A.sort()
ai = A[-1]

tmp = ai / 2
i = bisect.bisect_left(A, tmp)
if abs(tmp - A[i]) <= abs(tmp - A[i - 1]):
    print(ai, A[i])
else:
    print(ai, A[i - 1])

Submission status: Wrong Answer

Solution code:
import bisect
N = int(input())
A = list(map(int, input().split()))
A.sort()
ai = A[-1]

tmp1 = ai // 2
tmp2 = tmp1 + 1
i1 = bisect.bisect_left(A, tmp1)
i2 = bisect.bisect_left(A, tmp2)
if abs(tmp1 - A[i1]) <= abs(tmp2 - A[i2]):
    print(ai, A[i1])
else:
    print(ai, A[i2])

Submission status: Wrong Answer

Solution code:
import bisect
N = int(input())
A = list(map(int, input().split()))
A.sort()
ai = A[-1]

if (N % 2) == 0:
    tmp = ai // 2
    i = bisect.bisect_left(A, tmp)
    if abs(tmp - A[i]) <= abs(tmp - A[i - 1]):
        print(ai, A[i])
    else:
        print(ai, A[i - 1])
else:
    tmp1 = ai // 2
    tmp2 = tmp1 + 1
    i1 = bisect.bisect_left(A, tmp1)
    i2 = bisect.bisect_left(A, tmp2)
    if abs(tmp1 - A[i1]) <= abs(tmp2 - A[i2]):
        print(ai, A[i1])
    else:
        print(ai, A[i2])

Submission status: Wrong Answer

Solution code:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor


INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LIM(): return list(map(lambda x:int(x) - 1, sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def LIRM(n): return [LIM() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007




n = I()
L = sorted(LI())
a = L[-1]
L = L[:-1]
l = bisect_left(L, a / 2)
if l + 1 < n - 1 and L[l + 1] - a / 2 < a / 2 - L[l]:
    print(a, L[l + 1])
else:
    print(a, L[min(l, n-2)])

Submission status: Wrong Answer

Solution code:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor


INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LIM(): return list(map(lambda x:int(x) - 1, sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def LIRM(n): return [LIM() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007




n = I()
L = sorted(LI())
a = L[-1]
L = L[:-1]
l = bisect_left(L, a / 2)
if l + 1 < n and L[l + 1] - a / 2 < a / 2 - L[l]:
    print(a, L[l + 1])
else:
    print(a, L[min(l, n-2)])

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
import bisect


def solve(n: int, a: "List[int]"):
    a.sort()
    N = a[-1]
    i = bisect.bisect(a, N // 2)
    candidate = [a[i]]
    if i > 0:
        candidate.append(a[i-1])
    if i < n-1:
        candidate.append(a[i+1])
    m = N
    for c in candidate:
        if abs(N//2 - c) < abs(N//2 - m):
            m = c
    print(N, m)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    n = int(next(tokens))  # type: int
    a = [ int(next(tokens)) for _ in range(n) ]  # type: "List[int]"
    solve(n, a)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import bisect

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

A = sorted(A)

ans1 = A[-1]

ind = bisect.bisect_left(A, ans1/2)

if ind == N-1 :
    ans2 = A[ind-1]
elif N % 2 == 1 :
    ans2 = A[ind]
else :
    c = float("inf")
    for i in range(max(0,ind-1), min(N-1,ind+2)) :
        calc = abs(ans1/2 - A[i])
        if calc < c :
            ans2 = A[i]
            c = calc
print(ans1,ans2)

Submission status: Wrong Answer

Solution code:
import bisect

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

A = sorted(A)

ans1 = A[-1]

ind = bisect.bisect_left(A, ans1/2)

if ind == N-1 :
    ans2 = A[ind-1]
elif N % 2 == 1 :
    ans2 = A[ind]
else :
    c = float("inf")
    for i in range(max(0,ind-1), min(N,ind+2)) :
        calc = abs(ans1/2 - A[i])
        if calc < c :
            ans2 = A[i]
            c = calc
print(ans1,ans2)

Submission status: Wrong Answer

Solution code:
import bisect
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

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

A = sorted(A)

ma = A[-1]
A = A[:-1]
mi = -1
mid = ma/2

mid_ind = bisect.bisect_left(A, mid)
l = n-1
if mid_ind >= l:
    mi = A[-1]
elif mid_ind <= 0:
    mi = A[0]
else:
    if abs(A[mid_ind]-mid) > abs(A[mid_ind-1]):
        mi = A[mid_ind-1]
    else:
        mi = A[mid_ind]
print(ma, mi)

Submission status: Wrong Answer

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

ai = max(a)
a.remove(ai) 
ans = 0
for aj in a:
    if ans < min(aj,ai-aj):
        ans = aj
print(ai,ans)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
n = int(input())
a = [int(x) for x in input().split()]

maxa = max(a)
mida = a[0]
for x in a:
    # print(x,mida,maxa//2-x)
    if abs(maxa//2 - x)<abs(maxa//2-mida):
        mida = x
print(maxa, mida)

Submission status: Wrong Answer

Solution code:
N=int(input())
A=list(map(int,input().split()))
A1=max(A)
A2=(-1)
for i in range(N):
    if abs(A1/2-A[i])<abs(A1/2-A2):
        A2=A[i]
print(A1,A2)

Submission status: Wrong Answer

Solution code:
input()
a=list(map(int,input().split()))
m=max(a)
d=max(a,key=lambda d:abs(m-2*d)if m!=d else-1)
print(m,d)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
n = int(input())
a = list(map(int, input().split()))
x = max(a)
y = max(a, key=lambda a_i: min(a_i, x - a_i))
print(x, y)

Submission status: Wrong Answer

Solution code:
'''input
5
6 9 4 2 11
'''
n = input()
arr = map(int,raw_input().split())
m = max(arr)
zz = float(m)/2
diff = 10**20
for i in range(n):
	if abs(arr[i]-zz) < diff:
		diff = abs(arr[i]-zz)
		ans = arr[i]
print m,ans

Submission status: Wrong Answer

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

y = max(x)
sub = y
res = 0
for i in range(n):
    if abs(y/2-x[i]) < sub and x[i] != y:
        sub = y/2-x[i]
        res = x[i]

print(y,res)

Submission status: Wrong Answer

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

l = max(a)
r = 0
d = 10**9
for i in range(n):
    if (l == a[i]):
        break
    tmp = abs(l - 2*a[i])
    if (tmp < d):
        r = a[i]
        d = tmp

print("{0} {1}".format(l, r))

Submission status: Wrong Answer

Solution code:
import numpy as np
n=int(input())
A=[int(i) for i in input().split()]
ai=max(A)
j=np.argmin(np.array([abs(a-ai/2) for a in A]))
aj=A[j]
print(str(ai)+" "+str(aj))

Submission status: Wrong Answer

Solution code:
def Fc(n,r):
  t=1
  for i in range(int(n-r)):
    t = t*(n-i)
  return(t)

def Comb(n,r):
  return int(Fc(n,r)/Fc(r,0))

N=int(input())
a=list(map(int, input().strip().split(' ')))
asort=sorted(a)

maxn = [0,-1,-1] #現在の最大値,n,r
for i in range(N-1):
  n = asort[N-i-1]
  if n % 2 ==0:
    medn= n/2
  else:
    medn = (n+1)/2
  if maxn[0] > Comb(n,medn):#どうやっても越えられないならブレイク
    break
  flg = True
  r_ = medn #rの候補
  rp = medn+1
  rm = medn -1
  while flg:
    if(r_ in a):
      r=r_
      flg = False
    elif(rp in a):
      r=rp
      flg=False
    elif(rm in a):
      r=rm
      flg=False
    rp +=1
    rm -=1
  if Comb(n,r)>maxn[0]:
    maxn[0]=Comb(n,r)
    maxn[1]=n
    maxn[2]=r
n=maxn[1]
r=int(maxn[2])
print(str(n)+" "+str(r))

Submission status: Wrong Answer

Solution code:
def Fc(n,r):
  t=1
  for i in range(int(n-r)):
    t = t*(n-i)
  return(t)

def Comb(n,r):
  return int(Fc(n,r)/Fc(r,0))

N=int(input())
a=list(map(int, input().strip().split(' ')))
asort=sorted(a)

maxn = [0,-1,-1] #現在の最大値,n,r
for i in range(N-1):
  n = asort[N-i-1]
  if n % 2 ==0:
    medn= n/2
  else:
    medn = (n+1)/2
  if maxn[0] > Comb(n,medn):#どうやっても越えられないならブレイク
    break
  flg = True
  r_ = medn #rの候補
  rp = medn+1
  rm = medn -1
  while flg:
    if(r_ in a):
      r=r_
      flg = False
    elif(rp in a):
      r=rp
      flg=False
    elif(rm in a):
      r=rm
      fog=False
    rp +=1
    rm -=1
  if Comb(n,r)>maxn[0]:
    maxn[0]=Comb(n,r)
    maxn[1]=n
    maxn[2]=r
n=maxn[1]
r=int(maxn[2])
print(str(n)+" "+str(r))

Submission status: Wrong Answer

Solution code:
import numpy as np
import math

# def get_nearest_val(l, n, side='left'):
#     l = sorted(l)
#     i = np.searchsorted(l, n, side=side)
#     return l[i]

# def comb(n, r):
#     if n < 0 or r < 0 or n < r: return 0
#     elif n == 0 or r == 0: return 1
#     return comb(n-1, r-1) + comb(n-1, r)

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

def get_nearest_val(l, n):
    i = np.abs(np.asarray(l) - n).argmin()
    return l[i]

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

max_n = max(A)
key_r = (max_n + 1) / 2
# key_r = int((max_n + 1) / 2)
# print(key_r)

# left_r = get_nearest_val(A, key_r, side='left')
# # print(left_r)
# right_r = get_nearest_val(A, key_r, side='right')
# # print(right_r)

# left_comb = comb(max_n, left_r)
# # print(left_comb)
# right_comb = comb(max_n, right_r)
# # print(right_comb)

# if left_comb >= right_comb:
#     print(str(max_n) + ' ' + str(left_r))
# else:
#     print(str(max_n) + ' ' + str(right_r))

r = get_nearest_val(A, key_r)
print(str(max_n) + ' ' + str(r))

Submission status: Wrong Answer

Solution code:
import numpy as np
import math

def get_nearest_val(l, n, side='left'):
    l = sorted(l)
    i = np.searchsorted(l, n, side=side)
    return l[i]

# def comb(n, r):
#     if n < 0 or r < 0 or n < r: return 0
#     elif n == 0 or r == 0: return 1
#     return comb(n-1, r-1) + comb(n-1, r)

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

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

max_n = max(A)
key_r = (max_n + 1) / 2
# key_r = int((max_n + 1) / 2)
# print(key_r)

left_r = get_nearest_val(A, key_r, side='left')
# print(left_r)
right_r = get_nearest_val(A, key_r, side='right')
# print(right_r)

left_comb = comb(max_n, left_r)
# print(left_comb)
right_comb = comb(max_n, right_r)
# print(right_comb)

if left_comb >= right_comb:
    print(str(max_n) + ' ' + str(left_r))
else:
    print(str(max_n) + ' ' + str(right_r))

Submission status: Wrong Answer

Solution code:
import numpy as np

N = int(input())

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

a.sort()

a_max = a[N - 1]

ave = a_max / 2 + 1


dif = 1000000000
difidx = -1
difidx2 = -1
p = 1
s = 1


for i in range(N):
    an = abs(a[i] - ave)
    if dif > an:
        dif = an
        difidx = i
    elif dif == an:
        difidx2 = i

ans = a[difidx2] if difidx2 > 0 else a[difidx]
ans2 = str(a_max)
if N > 3:
    print(str(a_max) + " " + str(ans))
else:
    if a[0] > a[1]:
        print(str(a[0]) + " " + str(a[1]))
    else:
        print(str(a[1]) + " " + str(a[0]))

Submission status: Wrong Answer

Solution code:
import numpy as np

N = int(input())

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

a.sort()

a_max = a[N - 1]

ave = int(a_max / 2 + 1)


dif = 1000000000
difidx = -1
difidx2 = -1
p = 1
s = 1


for i in range(N):
    an = abs(a[i] - ave)
    if dif > an:
        dif = an
        difidx = i
    elif dif == an:
        difidx2 = i

ans = a[difidx2] if difidx2 > 0 else a[difidx]
ans2 = str(a_max)
if N > 3:
    print(str(a_max) + " " + str(ans))
else:
    if a[0] > a[1]:
        print(str(a[0]) + " " + str(a[1]))
    else:
        print(str(a[1]) + " " + str(a[0]))

Submission status: Wrong Answer

Solution code:
import numpy as np

N = int(input())

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

a.sort()

a_max = a[N - 1]

ave = int(a_max / 2)


dif = 1000000000
difidx = -1
difidx2 = -1
p = 1
s = 1


for i in range(N):
    an = abs(a[i] - ave)
    if dif > an:
        dif = an
        difidx = i
    elif dif == an:
        difidx2 = i

ans = a[difidx] if a[difidx] > a[difidx2] else a[difidx2]
ans2 = str(a_max)
if N > 3:
    print(str(a_max) + " " + str(ans))
else:
    if a[0] > a[1]:
        print(str(a[0]) + " " + str(a[1]))
    else:
        print(str(a[1]) + " " + str(a[0]))

Submission status: Wrong Answer

Solution code:
import numpy as np

N = int(input())

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

a.sort()

a_max = a[N - 1]

ave = int(a_max / 2)


dif = 1000000000
difidx = -1
difidx2 = -1
p = 1
s = 1


for i in range(N):
    an = abs(a[i] - ave)
    if dif > an:
        dif = an
        difidx = i
    elif dif == an:
        difidx2 = i

ans = a[difidx] if a[difidx] > a[difidx2] else a[difidx2]
if N > 3:
    print(str(a_max) + " " + str(ans))
else:
    print(str(a[0]) + " " + str(a[1]))

Submission status: Wrong Answer

Solution code:
n = int(input())
line = input().split(' ')
a = []
for element in line:
    a.append(int(element))

maxVal = max(a)
closestVal = a[0]
for x in a:
    if abs(x-maxVal/2) < abs(closestVal-maxVal/2):
        closestVal = x

print (maxVal, closestVal)

Submission status: Wrong Answer

Solution code:
n = int(input())
line = input().split(' ')
a = []
for element in line:
    a.append(int(element))

maxVal = max(a)
closestVal = a[0]
for x in a:
    if abs(x-maxVal//2) < abs(closestVal-maxVal//2) or abs(x-maxVal//2+1) < abs(closestVal-maxVal//2+1):
        closestVal = x

print (maxVal, closestVal)

Submission status: Wrong Answer

Solution code:
n = int(input())
line = input().split(' ')
a = []
for element in line:
    a.append(int(element))

maxVal = max(a)
closestVal = a[0]
for x in a:
    if abs(x-maxVal//2) < abs(closestVal-maxVal/2) or abs(x-maxVal//2+1) < abs(closestVal-maxVal/2):
        closestVal = x

print (maxVal, closestVal)

Submission status: Wrong Answer

Solution code:
n = int(input())
line = input().split(' ')
a = []
for element in line:
    a.append(int(element))

maxVal = max(a)
closestVal = a[0]
for x in a:
    if abs(x-maxVal/2) < abs(closestVal-maxVal/2):
        closestVal = x

print (maxVal, closestVal)

Submission status: Wrong Answer

Solution code:
import bisect
import numpy as np
n=input()
n=int(n)
lis = []
x = input()
x = x.split(" ")
for i in range(n):
    lis.append(float(x[i]))
lis2 = sorted(lis)
ans = np.zeros((n))
ans2 = np.zeros((n))
for i in range(n):
    temp = lis[i]/2
    if(temp==0):
        continue
    a = bisect.bisect_left(lis2,temp,lo=0,hi=n)
    fp = 1e18
    ans[i] = fp
    if(lis2[a]*(lis[i]-lis2[a])!=0):
        t = (temp/(lis2[a]*(lis[i]-lis2[a])));
        if(t<fp and t>=0):
            fp = t
            ans[i] = fp
            ans2[i] = a
    if(a-1<n):
        if(lis2[a-1]*(lis[i]-lis2[a-1])!=0):
            t = (temp/(lis2[a-1]*(lis[i]-lis2[a-1])))
            if(t<fp and t>=0):
                fp = t
                ans[i] = fp
                ans2[i] = a-1
    a = bisect.bisect_left(lis2,lis[i]-temp,lo=0,hi=n)
    if(lis2[a]*(lis[i]-lis2[a])!=0):
        t = (temp/(lis2[a]*(lis[i]-lis2[a])));
        if(t<fp and t>=0):
            fp = t
            ans[i] = fp
            ans2[i] = a
    if(a-1<n):
        if(lis2[a-1]*(lis[i]-lis2[a-1])!=0):
            t = (temp/(lis2[a-1]*(lis[i]-lis2[a-1])))
            if(t<fp and t>=0):
                fp = t
                ans[i] = fp
                ans2[i] = a-1
    #print(i,fp)

ty = 1e18;
gx, gy = 0, 0
for i in range(n):
    if(ans[i]<ty):
        ty = ans[i]
        gx = lis[i]
        gy = lis2[int(ans2[i])]
if(n==2):
    if(lis[0]>lis[1]):
        print(int(lis[0]),int(lis[1]))
    else:
        print(int(lis[1]),int(lis[0]))
elif(gx>gy):
    print(int(gx),int(gy))
else:
    print(int(gy),int(gx))

Submission status: Wrong Answer

Solution code:
import bisect
import numpy as np
n=input()
n=int(n)
lis = []
x = input()
x = x.split(" ")
for i in range(n):
    lis.append(float(x[i]))
lis2 = sorted(lis)
ans = np.zeros((n))
ans2 = np.zeros((n))
for i in range(n):
    temp = lis[i]/2
    a = bisect.bisect_left(lis2,temp,lo=0,hi=n)
    fp = 1e18
    ans[i] = fp
    if(lis2[a]*(lis[i]-lis2[a])!=0):
        t = (temp/(lis2[a]*(lis[i]-lis2[a])));
        if(t<fp and t>=0):
            fp = t
            ans[i] = fp
            ans2[i] = a
    if(a-1>=0):
        if(lis2[a-1]*(lis[i]-lis2[a-1])!=0):
            t = (temp/(lis2[a-1]*(lis[i]-lis2[a-1])))
            if(t<fp and t>=0):
                fp = t
                ans[i] = fp
                ans2[i] = a-1

    if(a+1<n):
        if(lis2[a+1]*(lis[i]-lis2[a+1])!=0):
            t = (temp/(lis2[a+1]*(lis[i]-lis2[a+1])))
            if(t<fp and t>=0):
                fp = t
                ans[i] = fp
                ans2[i] = a+1

    a = bisect.bisect_left(lis2,lis[i]-temp,lo=0,hi=n)
    if(lis2[a]*(lis[i]-lis2[a])!=0):
        t = (temp/(lis2[a]*(lis[i]-lis2[a])));
        if(t<fp and t>=0):
            fp = t
            ans[i] = fp
            ans2[i] = a
    if(a-1>=0):
        if(lis2[a-1]*(lis[i]-lis2[a-1])!=0):
            t = (temp/(lis2[a-1]*(lis[i]-lis2[a-1])))
            if(t<fp and t>=0):
                fp = t
                ans[i] = fp
                ans2[i] = a-1
    if(a+1<n):
        if(lis2[a+1]*(lis[i]-lis2[a+1])!=0):
            t = (temp/(lis2[a+1]*(lis[i]-lis2[a+1])))
            if(t<fp and t>=0):
                fp = t
                ans[i] = fp
                ans2[i] = a+1
    #print(i,fp)

ty = 1e18;
gx, gy = 0, 0
for i in range(n):
    if(ans[i]<ty):
        ty = ans[i]
        gx = lis[i]
        gy = lis2[int(ans2[i])]
if(n==2):
    if(lis[0]>lis[1]):
        print(int(lis[0]),int(lis[1]))
    else:
        print(int(lis[1]),int(lis[0]))
elif(gx>gy):
    print(int(gx),int(gy))
else:
    print(int(gy),int(gx))

Submission status: Wrong Answer

Solution code:
import bisect
import numpy as np
n=input()
n=int(n)
lis = []
x = input()
x = x.split(" ")
for i in range(n):
    lis.append(float(x[i]))
lis2 = sorted(lis)
ans = np.zeros((n))
ans2 = np.zeros((n))
for i in range(n):
    temp = lis[i]/2
    a = bisect.bisect_left(lis2,temp,lo=0,hi=n)
    fp = 1e18
    ans[i] = fp
    if(lis2[a]*(lis[i]-lis2[a])!=0):
        t = (temp/(lis2[a]*(lis[i]-lis2[a])));
        if(t<fp and t>=0):
            fp = t
            ans[i] = fp
            ans2[i] = a
    if(a-1<n):
        if(lis2[a-1]*(lis[i]-lis2[a-1])!=0):
            t = (temp/(lis2[a-1]*(lis[i]-lis2[a-1])))
            if(t<fp and t>=0):
                fp = t
                ans[i] = fp
                ans2[i] = a-1
    a = bisect.bisect_left(lis2,lis[i]-temp,lo=0,hi=n)
    if(lis2[a]*(lis[i]-lis2[a])!=0):
        t = (temp/(lis2[a]*(lis[i]-lis2[a])));
        if(t<fp and t>=0):
            fp = t
            ans[i] = fp
            ans2[i] = a
    if(a-1<n):
        if(lis2[a-1]*(lis[i]-lis2[a-1])!=0):
            t = (temp/(lis2[a-1]*(lis[i]-lis2[a-1])))
            if(t<fp and t>=0):
                fp = t
                ans[i] = fp
                ans2[i] = a-1
    #print(i,fp)

ty = 1e18;
gx, gy = 0, 0
for i in range(n):
    if(ans[i]<ty):
        ty = ans[i]
        gx = lis[i]
        gy = lis2[int(ans2[i])]
if(n==2):
    if(lis[0]>lis[1]):
        print(int(lis[0]),int(lis[1]))
    else:
        print(int(lis[1]),int(lis[0]))
elif(gx>gy):
    print(int(gx),int(gy))
else:
    print(int(gy),int(gx))

Submission status: Wrong Answer

Solution code:
import bisect
import numpy as np
n=input()
n=int(n)
lis = []
x = input()
x = x.split(" ")
for i in range(n):
    lis.append(float(x[i]))
lis2 = sorted(lis)
ans = np.zeros((n))
ans2 = np.zeros((n))
for i in range(n):
    temp = lis[i]/2
    a = bisect.bisect_left(lis2,temp,lo=0,hi=n)
    fp = 1e18
    ans[i] = fp
    if(lis2[a]*(lis[i]-lis2[a])!=0):
        t = (temp/(lis2[a]*(lis[i]-lis2[a])));
        if(t<fp and t>=0):
            fp = t
            ans[i] = fp
            ans2[i] = a


    if(a-1<n):
        if(lis2[a-1]*(lis[i]-lis2[a-1])!=0):
            t = (temp/(lis2[a-1]*(lis[i]-lis2[a-1])))
            if(t<fp and t>=0):
                fp = t
                ans[i] = fp
                ans2[i] = a-1
    #print(i,fp)

ty = 1e18;
gx, gy = 0, 0
for i in range(n):
    if(ans[i]<ty):
        ty = ans[i]
        gx = lis[i]
        gy = lis2[int(ans2[i])]
if(n==2):
    if(lis[0]>lis[1]):
        print(int(lis[0]),int(lis[1]))
    else:
        print(int(lis[1]),int(lis[0]))
elif(gx>gy):
    print(int(gx),int(gy))
else:
    print(int(gy),int(gx))

Submission status: Wrong Answer

Solution code:
import bisect
import numpy as np
n=input()
n=int(n)
lis = []
x = input()
x = x.split(" ")
for i in range(n):
    lis.append(float(x[i]))
lis2 = sorted(lis)
ans = np.zeros((n))
ans2 = np.zeros((n))
for i in range(n):
    temp = lis[i]/2
    a = bisect.bisect_left(lis2,temp,lo=0,hi=n)
    fp = 1e18
    ans[i] = fp
    if(lis2[a]*(lis[i]-lis2[a])!=0):
        t = (temp/(lis2[a]*(lis[i]-lis2[a])));
        if(t<fp and t>=0):
            fp = t
            ans[i] = fp
            ans2[i] = a

    # if(a+1<n):
    #     if(lis2[a+1]*(lis[i]-lis2[a+1])!=0):
    #         t = (temp/(lis2[a+1]*(lis[i]-lis2[a+1])));
    #         if(t<fp and t>=0):
    #             fp = t
    #             ans[i] = fp
    #             ans2[i] = a+1

    if(a-1<n):
        if(lis2[a-1]*(lis[i]-lis2[a-1])!=0):
            t = (temp/(lis2[a-1]*(lis[i]-lis2[a-1])))
            if(t<fp and t>=0):
                fp = t
                ans[i] = fp
                ans2[i] = a-1
    #print(i,fp)

ty = 1e18;
gx, gy = 0, 0
for i in range(n):
    if(ans[i]<ty):
        ty = ans[i]
        gx = lis[i]
        gy = lis2[int(ans2[i])]
if(gx>gy):
    print(int(gx),int(gy))
else:
    print(int(gy),int(gx))