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 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]-A[k]) > abs(A[l]-A[l]):
        ans = [A[-1],A[k]]
    else:
        ans = [A[-1],A[l]]
    
    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 comb(A[-1],A[k]) > comb(A[-1],A[l]):
        ans = [A[-1],A[k]]
    else:
        ans = [A[-1],A[l]]
    
    print(*ans)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
from bisect import bisect_left as bl
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)
    ans = []
    if 0 <= k-1 and k+1 < N:
        lis = [abs(A[k]-M),abs(A[k-1]-M),abs(A[k+1]-M)]
        d = [0,-1,1]
        for j in range(3):
            if min(lis) == lis[j]:
                ans.append([A[-1],A[k+d[j]]])
    elif 0 <= k-1:
        lis = [abs(A[k]-M),abs(A[k-1]-M)]
        d = [0,-1]
        for j in range(2):
            if min(lis) == lis[j]:
                ans.append([A[-1],A[k+d[j]]])
    elif N > k+1:
        lis = [abs(A[k]-M),abs(A[k+1]-M)]
        d = [0,1]
        for j in range(2):
            if min(lis) == lis[j]:
                ans.append([A[-1],A[k+d[j]]])
    else:
        ans.append([A[-1],A[k]])
    if len(ans) == 1:
        print(*ans)
    else:
        l = 0
        ret = []
        while ans:
            tmp = ans.pop()
            a,b = tmp
            if comb(a,b) > l:
                l = comb(a,b)
                ret = tmp
        print(*ret)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
from bisect import bisect_left as bl
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)
    ans = []
    if 0 <= k-1 and k+1 < N:
        lis = [abs(A[k]-M),abs(A[k-1]-M),abs(A[k+1]-M)]
        d = [0,-1,1]
        for j in range(3):
            if min(lis) == lis[j]:
                ans.append([A[-1],A[k+d[j]]])
    elif 0 <= k-1:
        lis = [abs(A[k]-M),abs(A[k-1]-M)]
        d = [0,-1]
        for j in range(2):
            if min(lis) == lis[j]:
                ans.append([A[-1],A[k+d[j]]])
    elif N > k+1:
        lis = [abs(A[k]-M),abs(A[k+1]-M)]
        d = [0,1]
        for j in range(2):
            if min(lis) == lis[j]:
                ans.append([A[-1],A[k+d[j]]])
    else:
        ans.append([A[-1],A[k]])
    if len(ans) == 1:
        print(*ans)
    else:
        l = 0
        ret = []
        while ans:
            tmp = ans.pop()
            a,b = tmp
            if comb(a,b) > l:
                ret = tmp
        print(*ret)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
from math import factorial
n=int(input())
A=list(map(int,input().split()))

a=max(A)
B=[]
for i in range(n):
    B.append(factorial(a)//((factorial(A[i])*factorial(a-A[i]))))

print(a,A[B.index(max(B))])

Submission status: Wrong Answer

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

a=max(A)

B=[]

for i in range(n):
    if A[i]==a:
        B.append(a)
    B.append(abs(A[i]-a/2))

ind=B.index(min(B))

b=A[ind]

print(a,b)

Submission status: Wrong Answer

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

a=max(A)

B=[]

for i in range(n):
    if A[i]==a:
        B.append(a)
    B.append(abs(A[i]-a//2))

ind=B.index(min(B))

b=A[ind]

print(a,b)

Submission status: Wrong Answer

Solution code:
#094_D
n = int(input())
a = sorted(list(map(int, input().split())))
m = a[-1]
mid = m // 2
l, r = 0, n - 1
while r - l > 1:
    x = (l + r) // 2
    if a[x] <= mid:
        l = x
    else:
        r = x
print(m, a[r])

Submission status: Wrong Answer

Solution code:
#094_D
n = int(input())
a = sorted(list(map(int, input().split())))
m = a[-1]
mid = m // 2
idx = 10 ** 10
for i in range(n-1):
    if abs(a[i]-mid) < abs(a[i]-idx):
        idx = a[i]
print(m, idx)

Submission status: Wrong Answer

Solution code:
from bisect import bisect_left


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

A.sort()
n = A[-1]

m = bisect_left(A, n / 2)
r = A[m] if abs(n - A[m]) <= abs(n - A[m - 1]) and m != N - 1 else A[m - 1]

print(n, r)

Submission status: Wrong Answer

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

a.sort()

candi = a[-1]
middle = (candi - 1) // 2

tmp = float("inf")
ans = 0

if candi % 2 == 1:
    for i in range(len(a) - 1):
        if tmp >= abs(a[i] - middle):
            tmp = abs(a[i] - middle)
            ans = i
else:
    for i in range(len(a) - 1):
        if tmp > abs(a[i] - middle):
            tmp = abs(a[i] - middle)
            ans = i
print(candi, a[ans])

Submission status: Wrong Answer

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

a.sort()

candi = a[-1]
middle = (candi - 1) // 2

tmp = float("inf")
ans = 0
for i in range(len(a) - 1):
    if tmp >= abs(a[i] - middle):
        tmp = abs(a[i] - middle)
        ans = i
print(candi, a[ans])

Submission status: Wrong Answer

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

combn = max(a)

ar = [abs(num-combn/2) for num in a]
combr = int(combn/2 - min(ar))

print(' '.join(map(str,[combn,combr])))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
a.sort()
M = max(a)
m = M//2
tmp = 1e9
for i in range(n-1):
    if tmp > abs(a[i]-m):
        tmp = abs(a[i]-m)
        ans = i

print(M,a[ans])

Submission status: Wrong Answer

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

A.sort()

ai = A[-1]

M = min(ai-A[0], A[0])
aj = A[0]

for i in range(N):
    m = min(ai-A[i], A[i])
    if M <= m:
        aj = A[i]
        M = m

print(ai,aj)

Submission status: Wrong Answer

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

A.sort()

ai = A[-1]

M = min(ai-A[0], A[0])
aj = A[0]

for i in range(N):
    m = min(ai-A[i], A[i])
    if M <= m:
        aj = A[i]
        M = m
    else:
        break

print(ai,aj)

Submission status: Wrong Answer

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

A.sort()

ai = A[-1]

M = min(ai-A[0], A[0])
aj = A[0]

for i in range(N):
    m = min(ai-A[i], A[i])
    if M < m:
        aj = A[i]
        M = m
    else:
        break

print(ai,aj)

Submission status: Wrong Answer

Solution code:
n=int(input())
 
t = list(map(int,input().split()))
 
a1 = max(t)
 
ans = 100000000000000
 
memo = 0

for i in t:
    if ans >= abs(a1//2-i):
        ans = abs(a1//2-i)
        memo = i
print(a1, memo)

Submission status: Wrong Answer

Solution code:
n=int(input())
 
t = list(map(int,input().split()))
 
a1 = max(t)
 
ans = 100000000000000
 
memo = 0

for i in t:
    if ans > abs(a1//2-i):
        ans = abs(a1//2-i)
        memo = i
print(a1, memo)

Submission status: Wrong Answer

Solution code:
import numpy as np
# + - - - - + even -> + + + + + + 全部プラス
# + - - - - - + odd -> どっか一個が -

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

num_negative = np.count_nonzero(A < 0)
A = np.abs(A)
if num_negative % 2 == 0:
    print(A.sum())
else:
    print(A.sum() - A.min() * 2)

Submission status: Wrong Answer

Solution code:
import bisect

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

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

if n%2==0:
    middleIdx=bisect.bisect_left(a[:N-1],n//2)
    if a[middleIdx]==n//2:
        r=a[middleIdx]
    elif a[min(middleIdx+1,N-2)]-a[middleIdx]>a[middleIdx]-a[max(middleIdx-1,0)]:
        r=a[max(middleIdx-1,0)]
    else:
        r=a[min(middleIdx+1,N-2)]
    print(n,r)
else:
    m1=bisect.bisect_left(a[:N-1],n//2)
    m2=bisect.bisect_left(a[:N-1],n//2+1)
    if a[m1]==n//2:
        r=a[m1]
    elif a[m2]==n//2+1:
        r=a[m2]
    elif a[min(m2+1,N-2)]-a[m2]>a[m1]-a[max(m1-1,0)]:
        r=a[max(m1-1,0)]
    else:
        r=a[min(m2+1,N-2)]
    print(n,r)

Submission status: Wrong Answer

Solution code:
import bisect

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

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

if n%2==0:
    middleIdx=bisect.bisect_left(a[:N-1],n//2)
    if a[middleIdx]==n//2:
        r=a[middleIdx]
    elif a[min(middleIdx+1,N-1)]-a[middleIdx]>a[middleIdx]-a[max(middleIdx-1,0)]:
        r=a[min(middleIdx+1,N-1)]
    else:
        r=a[max(middleIdx-1,0)]
    print(n,r)
else:
    m1=bisect.bisect_left(a[:N-1],n//2)
    m2=bisect.bisect_left(a[:N-1],n//2+1)
    if a[m1]==n//2:
        r=a[m1]
    elif a[m2]==n//2+1:
        r=a[m2]
    elif a[min(m2+1,N-1)]-a[m2]>a[m1]-a[max(m1-1,0)]:
        r=a[min(m2+1,N-1)]
    else:
        r=a[max(m1-1,0)]
    print(n,r)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
x = max(a)
half = x/2
y = sorted(a, key=lambda x: abs(half-x))[0]
print("{} {}".format(x,y))

Submission status: Wrong Answer

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

left = max(A)

right = 0
dif_min = 10**10
mid = (max(A)//2) + 1

for i in range(n):
    if A[i] == left:
        continue
    dif = abs(A[i] - mid)
    if dif <= dif_min:
        dif_min = dif
        right = A[i]

print(str(left) + ' ' + str(right))

Submission status: Wrong Answer

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

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

ans = [-1, 0, 0]

import bisect

i = a[-1]
idx = [bisect.bisect_left(a, i // 2), bisect.bisect_left(a, i // 2) - 1]

if abs(i // 2 - a[idx[0]]) < abs(i // 2 - a[idx[1]]):
    print(i, a[idx[0]])    
else:
    print(i, a[idx[1]])

Submission status: Wrong Answer

Solution code:
from bisect import bisect

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

x=a[-1]
if n%2==0:
  mid=x//2
  if mid in a:
    print(x,mid)
  else:
    inx=bisect(a,mid)
    if a[inx]-mid>=mid-a[inx]:
      print(x,a[inx-1])
    else:
      print(x,a[inx])
else:
  mid=x//2+1
  if mid in a:
    print(x,mid)
  else:
    inx=bisect(a,mid)
    if a[inx]-mid>=mid-a[inx-1]:
      print(x,a[inx-1])
    else:
      print(x,a[inx])

Submission status: Wrong Answer

Solution code:
from bisect import bisect

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

x=a[-1]
if n%2==0:
  mid=x//2
  if mid in a:
    print(x,mid)
  else:
    inx=bisect(a,mid)
    if a[inx]-mid>=mid-a[inx]:
      print(x,a[inx])
    else:
      print(x,a[inx-1])
else:
  mid=x//2+1
  if mid in a:
    print(x,mid)
  else:
    inx=bisect(a,mid)
    if a[inx]-mid>=mid-a[inx-1]:
      print(x,a[inx-1])
    else:
      print(x,a[inx])

Submission status: Wrong Answer

Solution code:
from bisect import bisect

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

x=a[-1]
if n%2==0:
  mid=x//2
  if mid in a:
    print(x,mid)
  else:
    inx=bisect(a,mid)
    if a[inx]-mid>=mid-a[inx]:
      print(x,a[inx-1])
    else:
      print(x,a[inx-1])
else:
  mid=x//2+1
  if mid in a:
    print(x,mid)
  else:
    inx=bisect(a,mid)
    if a[inx]-mid>=mid-a[inx-1]:
      print(x,a[inx-1])
    else:
      print(x,a[inx])

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
ans_bigger = max(a)
ans_half = ans_bigger / 2
dif = float("inf")
for i in range(n):
  x = abs(a[i]-ans_half)
  if dif > x:
    dif = x
    ans_smaller = a[i]
print(ans_bigger,ans_smaller)

Submission status: Wrong Answer

Solution code:
n = map(int, input().split())
alist = list(map(int, input().split()))
m = max(alist)
sbn = 10**10
for a in alist:
    if abs(m/2 - a) < sbn:
        ans = a
        sbn = abs(m/2 - a)
print(m, ans)

Submission status: Wrong Answer

Solution code:
n = map(int, input().split())
alist = list(map(int, input().split()))
m = max(alist)
sbn = 10**10
for a in alist:
    if m/2 - a < sbn:
        ans = a
        sbn = m/2 - a
print(m, ans)

Submission status: Wrong Answer

Solution code:
import bisect
n = int(input())
a = sorted(list(map(int,input().split())))
ans = 0
mini = float('inf')
for i in range(n):
    if mini > abs(a[i]-a[n-1]//2):
        ans = i
        mini = abs(a[i]-a[n-1]//2)
if a[ans] == 0:
    print(a[n-1],a[ans+1])
else:
    print(a[n-1],a[ans])

Submission status: Wrong Answer

Solution code:
import bisect
n = int(input())
a = sorted(list(map(int,input().split())))
ans = 0
mini = float('inf')
for i in range(n):
    if mini > abs(a[i]-a[n-1]//2) and a[i] != 0:
        ans = i
        mini = abs(a[i]-a[n-1]//2)
print(a[n-1],a[ans])

Submission status: Wrong Answer

Solution code:
import bisect
n = int(input())
a = sorted(list(map(int,input().split())))
ans = 0
mini = float('inf')
for i in range(n):
    if mini > abs(a[i]-a[n-1]//2):
        ans = i
        mini = abs(a[i]-a[n-1]//2)
if ans == 0:
    print(a[n-1],a[1])
else:
    print(a[n-1],a[ans])

Submission status: Wrong Answer

Solution code:
import bisect
n = int(input())
a = sorted(list(map(int,input().split())))
ans = 0
mini = float('inf')
for i in range(n):
    if mini > abs(a[i]-a[n-1]//2):
        ans = i
        mini = abs(a[i]-a[n-1]//2)
print(a[n-1],a[ans])

Submission status: Wrong Answer

Solution code:
import bisect
n = int(input())
a = sorted(list(map(int,input().split())))
t = bisect.bisect_left(a,a[n-1]//2)
if t == 0:
    print(a[n-1],a[t])
else:
    if abs(a[n-1]//2-a[t]) > abs(a[n-1]//2-a[t-1]):
        print(a[n-1],a[t-1])
    else:
        print(a[n-1],a[t])

Submission status: Wrong Answer

Solution code:
import bisect

N = int(input())
a = list(map(int,input().split()))
a.sort()
a_max = a.pop()
idx = bisect.bisect_left(a,a_max/2)
print(a_max,a[idx] if idx < N-1 else a[N-2])

Submission status: Wrong Answer

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

x = max(A)
mid = -(-x // 2)
diff_src = 10**9+1
for a in A:
    diff_dst = abs(a-mid)
    if (diff_dst < diff_src):
        y = a
        diff_src = diff_dst

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

Submission status: Wrong Answer

Solution code:
def sq(a, b, mod):  # aのb乗を剰余,kは初期値#20191116-D-Knight
    if b == 0:
        return 1
    elif b % 2 == 0:
        return sq(a, b // 2, mod)**2 % mod
    else:
        return sq(a, b - 1, mod) * a % mod


def nCk(n, k, mod=10 ** 9 + 7):
    x = max(k, n - k)
    y = min(k, n - k)
    kkai = 1
    for i in range(2, y + 1):
        kkai = (kkai * i) % mod
    nkkai = 1
    for i in range(x + 1, n + 1):
        nkkai = (nkkai * i) % mod
    answer = sq(kkai, mod - 2, mod) * nkkai % mod
    return answer

n = int(input())
alist = list(map(int, input().split()))
m = max(alist)
ans = 0
ans_ = (0, 0)
sbn = 10**10
for a in alist:
    sbn_ = m-a
    if sbn_ < sbn:
        sbn = sbn_
        nck = nCk(m, a)
        # print(nck)
        ans = nck
        ans_ = (m, a)
print(ans_[0], ans_[1])

Submission status: Wrong Answer

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

MAX=max(a)
Harf=MAX/2

cnt=10**20
ans=0
for i in range(n):
    if abs(Harf-a[i])<cnt:
        ans=a[i]
        cnt=abs(Harf-a[i])
print(MAX,ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
ans_1 = max(A)
A.remove(ans_1)
ans_2 = 0
d = 100000000
for e in A:
    if d > abs(float(ans_1)/2-e):
        d = abs(float(ans_1)/2-e)
        ans_2 = e
print(ans_1,ans_2)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
ans_1 = max(A)
A.remove(ans_1)
ans_2 = 0
d = 1000000
for e in A:
    if d > abs(ans_1/2-e):
        d = abs(ans_1/2-e)
        ans_2 = e
print(ans_1,ans_2)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
ans_1 = max(A)
ans_2 = 0
d = 1000000
for e in A:
    if d > abs(ans_1/2-e):
        d = abs(ans_1/2-e)
        ans_2 = e
print(ans_1,ans_2)

Submission status: Wrong Answer

Solution code:
import numpy as np

N = int(input())
M, *A = sorted(map(int, input().split()), reverse=True)
if N == 2:
    print(M, *A)
    quit()

A = np.abs(np.array(A, dtype=np.int64) - M / 2)
A.sort()
print(M, int(A[0] + M / 2))

Submission status: Wrong Answer

Solution code:
from bisect import bisect_left
from scipy.misc import comb

N = int(input())
A = sorted(map(int, input().split()))
if N == 2:
    print(*A[::-1])
    quit()

n = A.pop()
idx = bisect_left(A, n // 2)
print(n, (A[idx] if comb(n, A[idx]) > comb(n, A[idx - 1]) else A[idx - 1]))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = sorted(map(int, input().split()))
MAX = a[-1]
mid = MAX // 2
b = float('inf')
for i in a:
    # print(mid, i, b)
    if abs(mid - i) < b:
        b = mid - i
        y = i

print(MAX, y)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = sorted(map(int, input().split()))
MAX = a[-1]
mid = MAX // 2
b = float('inf')
for i in a:
    # print(mid, i, b)
    if abs(mid - i) <= b:
        b = mid - i
        y = i

print(MAX, y)

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())
    numbers = list(map(int, input().split(" ")))
    numbers.sort()
    if n > 2:
        if numbers[-1] % 2:
            target = (numbers[-1] - 1) // 2
        else:
            target = numbers[-1] // 2
        upper = n - 1
        lower = 0
        while lower + 1 < upper:
            if numbers[(lower + upper) // 2] < target:
                lower = (lower + upper) // 2
            else:
                upper = (lower + upper) // 2
        print(numbers[-1], numbers[upper])
    else:
        print(numbers[1], numbers[0])


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    n = int(input())
    numbers = list(map(int, input().split(" ")))
    numbers.sort()
    if n > 2:
        if numbers[-1] % 2:
            target = (numbers[-1] + 1) // 2
        else:
            target = numbers[-1] // 2
        upper = n - 1
        lower = 0
        while lower + 1 < upper:
            if numbers[(lower + upper) // 2] < target:
                lower = (lower + upper) // 2
            else:
                upper = (lower + upper) // 2
        print(numbers[-1], numbers[upper])
    else:
        print(numbers[1], numbers[0])


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import bisect
N=int(input())
A=list(map(int,input().split()))
if N==2:
  print(max(A),min(A))
else:
  B=sorted(A)
  a=B[-1]
  B=B[:N-1]
  b=bisect.bisect_left(B,a/2)
  print(a,B[b])

Submission status: Wrong Answer

Solution code:
import bisect

def main():
    N = int(input())
    a = [int(i) for i in input().split()]

    a.sort()
    n = a[-1]
    m = n // 2
    right = bisect.bisect_right(a, m)

    if a[right-1] == m:
        r = m

    elif m - a[right-1] <= a[right] - m:
        r = a[right-1]

    else:
        r = a[right]

    print(n, r)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
a_i = max(a)
a.sort(key=lambda x: abs(a_i/2-x))

print(a_i, a[0])

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
a.sort(reverse=True)
left = 0
right = 1
while right < n:
    a_i = a[left]
    a_j = a[right]
    index = (a_i//2 if a_i % 2 == 0 else a_i/2)
    if a_j - index > 0:
        pass
    else:
        if index - a_j < a[right-1] - index:
            ans = (a[left], a_j)
        else:
            ans = (a[left], a[right-1])
        break

print(*ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
l = list(map(int, input().split()))
l.sort()
m = l.pop()
a = 0
ans = 0
for r in l:
  if abs(((m + 1) / 2) - r) < a:
    a = abs(((m + 1) / 2) - r)
    ans = r
print(m, ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
l = list(map(int, input().split()))
l.sort()
m = l.pop()
a = 0
ans = 0
for r in l:
  if abs((m / 2) - r) < a:
    a = abs((m / 2) - r)
    ans = r
print(m, ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = set([int(c) for c in input().split()])
a = sorted(list(a))
X = a[-1]//2+1
m = 10**9
x = 0
for i in range(N-1):
  if abs(a[i]-X)<m:
    m = abs(a[i]-X)
    x = i
print(a[-1],a[x])

Submission status: Wrong Answer

Solution code:
from bisect import bisect_left

N = int(input())
a = set([int(c) for c in input().split()])
a = sorted(list(a))
X = a[-1]//2
i = bisect_left(a, X)
j = i-1 if i>0 else 0
h = i+1 if i<N-1 else N-1
I = abs(a[i]-X//2)
J = abs(a[j]-X//2)
H = abs(a[h]-X//2)
if min(I,J,H)==I and I!=N-1:
  print(a[-1],a[i])
elif min(I,J,H)==H and H!= N-1:
  print(a[-1],a[h])
else:
  print(a[-1],a[j])

Submission status: Wrong Answer

Solution code:
import scipy.misc

N=int(input())
X=list(map(int,input().split()))
SX=sorted(X)
M=SX.pop()
MV=10**9
ANS=0
for x in SX:
  z = M - x
  if MV > z:
    MV = z
    ANS = x
print("{} {}".format(M,ANS))

Submission status: Wrong Answer

Solution code:
import math
import bisect
s = int(input())
a = list(map(int, input().split()))
#aa = sorted(a,reverse=True)
aaa = sorted(a)
v = 0
def combination(n,r):
	return math.factorial(n) // (math.factorial(n-r) * math.factorial(r))
m = aaa[-1]
x = bisect.bisect_left(aaa,m//2)
if aaa[x] == m:
	x -= 1
print (m,aaa[x])

Submission status: Wrong Answer

Solution code:
import math
import bisect
s = int(input())
a = list(map(int, input().split()))
aa = sorted(a,reverse=True)
aaa = sorted(a)
v = 0
def combination(n,r):
	return math.factorial(n) // (math.factorial(n-r) * math.factorial(r))
for i in range(s):
	x = bisect.bisect_left(aaa, aa[i]//2)
	#print (combination(aa[i],aaa[x]),combination(aa[i],aaa[x+1]))
	m = combination(aa[i],aaa[x]) 
	if m > v:
		v = m
		a1 = aa[i]
		a2 = aaa[x]
	#v = max(v,combination(aa[i],aaa[x]),combination(aa[i],aaa[x+1]))
print (a1,a2)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys

read = lambda: sys.stdin.readline().rstrip()

class Solution(object):
    def binomial_coefficients(self, n, A):

        n0 = max(A)
        print(n0)
        mid, r, cur = n0 / 2, -1, float("inf")
        for i in A:
            if i != n0:
                x = abs(mid - i)
                if x < cur:
                    r, cur = i, x
        return n0, r

def main():
    n0 = int(read())
    A0 = tuple(map(int, read().split()))

    res0, res1 = Solution().binomial_coefficients(n0, A0)

    print(res0, res1)
 
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
#import numpy as np
#import math
import sys

read = lambda: sys.stdin.readline().rstrip()

class Solution(object):
    def binomial_coefficients(self, n, A):

        n0 = max(A)
        mid, r, cur = n0 / 2, -1, float("inf")
        for i in A:
            if i != n0:
                x = abs(mid - i)
                if x < cur:
                    r, cur = i, x
        return n, r

def main():
    n0 = int(read())
    A0 = tuple(map(int, read().split()))

    res0, res1 = Solution().binomial_coefficients(n0, A0)

    print(res0, res1)
 
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
#import numpy as np
#import math
import sys

read = lambda: sys.stdin.readline().rstrip()

class Solution(object):
    def binomial_coefficients(self, n, A):

        num_max = max(A)
        min_val = float("inf")
        num_min = -1

        for i in range(n):
            if abs(A[i]-num_max/2) < min_val and A[i] !=  num_max:
                min_val, num_min = A[i]-num_max/2, A[i]

        return num_max, num_min

def main():
    n0 = int(read())
    A0 = tuple(map(int, read().split()))

    res0, res1 = Solution().binomial_coefficients(n0, A0)

    print(res0, res1)
 
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
#import numpy as np
#import math
import sys

read = lambda: sys.stdin.readline().rstrip()

class Solution(object):
    def binomial_coefficients(self, n, A):

        num_max = max(A)
        max_index = A.index(num_max)
        min_val = 1000000001.0
        num_min = -1

        for i in range(n):
            if abs(A[i]-num_max/2) < min_val and i != max_index:
                min_val, num_min = A[i]-num_max/2, A[i]

        return num_max, num_min

def main():
    n0 = int(read())
    A0 = tuple(map(int, read().split()))

    res0, res1 = Solution().binomial_coefficients(n0, A0)

    print(res0, res1)
 
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
#import numpy as np
#import math
import sys

read = lambda: sys.stdin.readline().rstrip()

def cmb(n,r):
    from operator import mul
    from functools import reduce
    
    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

class Solution(object):
    def binomial_coefficients(self, n, A):

        num_max = max(A)
        max_index = A.index(num_max)
        min_val = 1000000001.0
        num_min = 0

        for i in range(n):
            if abs(float(A[i]-float(num_max/2))) < min_val and i != max_index:
                min_val = A[i]-float(num_max/2)
                num_min = A[i]

        return num_max, num_min

def main():
    n0 = int(read())
    A0 = tuple(map(int, read().split()))

    res0, res1 = Solution().binomial_coefficients(n0, A0)

    print(res0, res1)
 
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
#import numpy as np
#import math
import sys

read = lambda: sys.stdin.readline().rstrip()

def cmb(n,r):
    from operator import mul
    from functools import reduce
    
    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

class Solution(object):
    def binomial_coefficients(self, n, A):

        num_max = max(A)
        max_index = A.index(num_max)
        min_val = 1000000001
        num_min = 0

        for i in range(n):
            if abs(A[i]-num_max/2) < min_val and i != max_index:
                min_val = A[i]-num_max/2
                num_min = A[i]

        return num_max, num_min

def main():
    n0 = int(read())
    A0 = tuple(map(int, read().split()))

    res0, res1 = Solution().binomial_coefficients(n0, A0)

    print(res0, res1)
 
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
#import numpy as np
#import math
import sys

read = lambda: sys.stdin.readline().rstrip()

def cmb(n,r):
    from operator import mul
    from functools import reduce
    
    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

class Solution(object):
    def binomial_coefficients(self, n, A):

        num_max = max(A)
        min_val = 1000000001
        num_min = 0

        for i in range(n):
            if abs(A[i]-num_max/2) < min_val:
                min_val = A[i]-num_max/2
                num_min = A[i]

        return num_max, num_min

def main():
    n0 = int(read())
    A0 = tuple(map(int, read().split()))

    res0, res1 = Solution().binomial_coefficients(n0, A0)

    print(res0, res1)
 
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

def comb(a, b):
  s = 1
  for i in range(a, b, -1):
    s *= i
  return s/2
import math

MA = max(A)
ans = (0, 0)
AL = 0
for i in A:
  if i == MA:
    continue
  if i < int(MA / 2) - 1:
    continue
  r = math.factorial(MA) // (math.factorial(MA-i) * math.factorial(i))
  if AL < r:
    AL = r
    ans = (MA, i)
    
print(ans[0], ans[1])

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
a.sort()
k = a[-1]
top = n
bottom = 0
while  top - bottom > 1:
    mid = ( top + bottom )//2
    if a[mid] <= k/2:
        bottom = mid
    else:
        top = mid
print(k)
sa = abs(a[bottom] -(k/2))
if bottom+1 < n-1 and abs(a[bottom+1]-(k/2)) < sa:
    print(a[bottom+1])
else:
    print(bottom)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
a.sort()
k = a[-1]
top = n
bottom = 0
while  top - bottom > 1:
    mid = ( top + bottom )//2
    if a[mid] <= k//2:
        bottom = mid
    else:
        top = mid
print(k)
sa = abs(a[bottom] -(k//2))
if bottom+1 < n-1 and abs(a[bottom+1]-(k//2)) < sa:
    print(a[bottom+1])
else:
    print(bottom)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
a.sort()
k = a[-1]
top = n
bottom = 0
while  top - bottom > 1:
    mid = ( top + bottom )//2
    if a[mid]*2 <= k:
        bottom = mid
    else:
        top = mid
print(k)
sa = abs(a[bottom] -(k//2))
if bottom+1 < n-1 and abs(a[bottom+1]-(k//2)) < sa:
    print(a[bottom+1])
else:
    print(bottom)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
a.sort()
k = a[-1]
top = n
bottom = 0
while  top - bottom > 1:
    mid = ( top + bottom )//2
    if a[mid]*2 <= k:
        bottom = mid
    else:
        top = mid
print(k)
sa = abs(a[bottom]*2 -k)
if bottom+1 < n-1 and abs(a[bottom+1]*2-k) < sa:
    print(a[bottom+1])
else:
    print(bottom)

Submission status: Wrong Answer

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

max_a = max(a_list)
half_max = max_a / 2
near = max_a
near_ori = max_a
for a in a_list:
    tmp = abs(a - half_max)
    if tmp < near:
        near = tmp
        near_ori = a
        
print(max_a, near_ori)