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:
def ans():
    n = int(input())
    a = list(map(int, input().split()))

    def comb(x, y):
        c = 1
        p = 1
        for i in range(y, 0, -1):
            c = c * i
        for i in range(x, x - y, -1):
            p = p * i
        return p / c

    p = max(a)
    want_near = p / 2
    tmp = 1
    tmpdiff = 9999999
    a.remove(p)
    for i in a:
        diff = abs(i - want_near)
        if diff < tmpdiff:
            tmpdiff = diff
            tmp = i

    return "{0} {1}".format(p, tmp)


print(ans())

Submission status: Wrong Answer

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

    def comb(x, y):
        c = 1
        p = 1
        for i in range(y, 0, -1):
            c = c * i
        for i in range(x, x - y, -1):
            p = p * i
        return p / c

    p = max(a)
    want_near = p // 2
    tmp = 1
    tmpdiff = 9999999
    a.remove(p)
    for i in a:
        diff = abs(i - want_near)
        if diff < tmpdiff:
            tmpdiff = diff
            tmp = i

    return "{0} {1}".format(p, tmp)


print(ans())

Submission status: Wrong Answer

Solution code:
n = int(input())
a_list = list(map(int, input().split()))
a_list.sort()
max_num = max(a_list)
a_list.pop()
n_half = max_num / 2
a_list_dif = [abs(i - n_half) for i in a_list]
min_idx = 0
min_val = float('inf')
for idx, v in enumerate(a_list_dif):
    if v < min_val:
        min_idx = idx
print(max_num, a_list[min_idx])

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

def comb(n, r):
    result = 1
    for i in range(r):
        result = int(result * (n - i) / (i + 1))

    return result

# Nを取得
n = int(input())

# Aiを取得
a_list = list(map(int, input().split()))

# 昇順にソートしたAiを取得
a_sorted = sorted(a_list)

# 最大値およびその1/2の値を取得
a_max = max(a_sorted)
a_max_half = a_max / 2

# 最大値の1/2に最も近いAiを取得
r = 0
for a in a_sorted:
    if abs(a_max_half - a) < abs(a_max_half - r):
        r = a
    else:
        break

# c = comb(a_max, r)

# 結果を出力
print("{} {}".format(a_max, r))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

def comb(n, r):
    result = 1
    for i in range(r):
        result = int(result * (n - i) / (i + 1))

    return result

# Nを取得
n = int(input())

# Aiを取得
a_list = list(map(int, input().split()))

# 昇順にソートしたAiを取得
a_sorted = sorted(a_list)

# 最大値およびその1/2の値を取得
a_max = max(a_sorted)
a_max_half = a_max / 2

# 最大値の1/2に最も近いAiを取得
r = 0
for a in a_sorted:
    if abs(a_max_half - a) >= abs(a_max_half - r):
        break
    else:
        r = a

# c = comb(a_max, r)

# 結果を出力
print("{} {}".format(a_max, r))

Submission status: Wrong Answer

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

a.sort()

old = 0
for item in a[:-1]:
    if abs(old - a[-1]/2) <= abs(item - a[-1]/2):
        print(a[-1], old)
        break
    old = item

Submission status: Wrong Answer

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

a.sort()

old = 0
for item in a:
    if abs(old - a[-1]/2) <= abs(item - a[-1]/2):
        print(a[-1], old)
        break
    old = item

Submission status: Wrong Answer

Solution code:
n = int(input())
A = list(map(int, input().split()))
m = max(A) 
min = float("inf")
for i in range(n):
  if min > abs(A[i] - m/2): 
    min = abs(A[i] - m/2)
    r = A[i]
print(m,r)

Submission status: Wrong Answer

Solution code:
import sys
import numpy
import math

N=int(input())

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

dekaiyatu=numpy.argmax(A)
kati=A[dekaiyatu]

A.pop(dekaiyatu)
iikanjinoyatu= numpy.argmin(list(map((lambda x: abs((dekaiyatu/2)-x) ), A)))

string=str(kati)+" "+str(A[iikanjinoyatu])

print(string)

Submission status: Wrong Answer

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

r = max(a)
Len = a[0] - r/2
l = a[0]
for i in range(n):
    if abs(a[i] - r/2) <= Len:
        l = a[i]

print("%d %d" % (r, l))

Submission status: Wrong Answer

Solution code:
n = int(input())
an = [int(i) for i in input().split()]
ai = max(an)
print("%d %d"%(ai, min(an, key=lambda i:abs(ai-i*2))))

Submission status: Wrong Answer

Solution code:
n = int(input())
an = [int(i) for i in input().split()]
ai = max(an)
print(ai, min(an, key=lambda i:abs(ai-i**2)))

Submission status: Wrong Answer

Solution code:
n = int(input())
an = [int(i) for i in input().split()]
ai = max(an)
print("%d %d"%(ai, min(an, key=lambda i:abs(ai-i**2))))

Submission status: Wrong Answer

Solution code:
from bisect import bisect_left
n = int(input())
a = [int(i) for i in input().split()]
a.sort()
x = a[-1]
b = (x+1)*1.0/2
num = bisect_left(a,int(b))
if num==0: y = a[0]
else:
	if b-a[num-1] >= a[num]-b: y = a[num]
	else: y = a[num-1]
print(x,y)

Submission status: Wrong Answer

Solution code:
n = int(input())
l = sorted(list(map(int, input().split())))
base = l[-1]
ans = 0
a = base//2
diff = float('Inf')
for i in l:
  if abs(a-i) <= diff:
    diff = abs(a-i)
    ans = i

print(base, ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
l = sorted(list(map(int, input().split())))
base = l[-1]
ans = 0
a = base//2
diff = float('Inf')
for i in l:
  if abs(a-i) < diff:
    diff = abs(a-i)
    ans = i

print(base, ans)

Submission status: Wrong Answer

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

a.sort()
a.reverse()
max = 0

for i in range(1, n):
  m = min(a[0] - a[i], a[i])
  #c = comb(a[0], a[i])
  if m > max:
    max = m
  else:
    i -= 1
    break

print(a[0], a[i])

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

n = int(input())
a = list(map(int, input().split()))
a_max = max(a)
half_max = a_max / 2
tmp = [abs(half_max - v) for v in a]
b = a[tmp.index(min(tmp))]
print("{} {}".format(a_max, b))

Submission status: Wrong Answer

Solution code:
from decimal import *
n = int(input())

number_list = list(map(int,input().split()))
number_list.sort()
max_number = max(number_list)
middle_number = Decimal(max_number) / Decimal(2)
for i in range(len(number_list)-1):
    if (number_list[i]-float(middle_number))*(number_list[i+1]-float(middle_number)) < 0:
        if abs(number_list[i]-middle_number) <= abs(number_list[i+1]-middle_number):
            print(max_number,number_list[i])
            break
        else:
            print(max_number,number_list[i+1])
            break
    else:
        pass

Submission status: Wrong Answer

Solution code:
n=int(input())
X_list=list(map(int,input().split()))
Max=max(X_list)
ans=float("inf")
res=0
for i in X_list:
    b=abs(Max/2-i)
    if ans>b:
        ans=b
        res=i
print(Max,res)

Submission status: Wrong Answer

Solution code:
from decimal import *

def fac(a,b):
    num = 1
    for i in range(a,b+1):
        num *= i
    return num

def comb(i,j):
    case = Decimal(fac(i-j+1,i)) / Decimal(fac(1,j))
    return case

n = int(input())

number_list = list(map(int,input().split()))
number_list.sort()
max_number = max(number_list)
middle_number = max_number/2
for i in range(len(number_list)-1):
    if (number_list[i]-middle_number)*(number_list[i+1]-middle_number) < 0:
        if abs(number_list[i]-middle_number) <= abs(number_list[i+1]-middle_number):
            print(max_number,number_list[i])
            break
        else:
            print(max_number,number_list[i+1])
    else:
        pass

Submission status: Wrong Answer

Solution code:
n = int(input())
l = sorted(list(map(int, input().split())))
base = l[-1]
ans = 0
a = base//2+1
for i in l:
  if i <= a:
    ans = i

print(base, ans)

Submission status: Wrong Answer

Solution code:
import math
n = int(input())
a = sorted(list(map(int,input().split())))
maxa = a[n-1]
for i in range(n-1):
    if a[i] < maxa/2:
        b = a[i]
        if i == n-2:
            print(str(maxa)+" "+str(b))
    else:
        print(i)
        c = math.factorial(b)*math.factorial(maxa-b)/(math.factorial(a[i])*math.factorial(maxa-a[i]))
        if c > 1:
            print(str(maxa)+" "+str(a[i]))
            break
        else:
            print(str(maxa)+" "+str(b))
            break

Submission status: Wrong Answer

Solution code:
INF = -1
n = int(input())
a = [int(i) for i in input().split()]
a.sort()
ai = a[n - 1]
aj = a[int((n-1)/2)]
print(ai, aj)

Submission status: Wrong Answer

Solution code:
import math

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

if __name__ == '__main__':
	n = int(input())
	a = [int(x) for x in input().split(' ')]

	sa = sorted(a)

	i, j = (0, n-1)
	while True:
		p = (sa[i], sa[i+1])
		q = (sa[j-1], sa[j])
		if i == j-1:
			print('{} {}'.format(sa[j],sa[i]))
			break
		elif i+1 == j-1:
			prod = (comb(p[0],q[0]), comb(p[0],q[1]), -1, comb(p[1],q[1]))
		else:
			prod = (comb(p[0],q[0]), comb(p[0],q[1]), comb(p[1],q[0]), comb(p[1],q[1]))
		print(prod)
		m = max(((v, i) for i, v in enumerate(prod)))
		if m[1] == 2 or m[1] == 3:
			i+=1
		if m[1] == 0 or m[1] == 2:
			j-=1
		if m[1] == 1:
			print('{} {}'.format(sa[j],sa[i]))
			break

Submission status: Wrong Answer

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

n_output=max(A)
mean=n_output/2
r=10000000000
r_output=10000000000
for i in range (n):
    if abs(A[i]-mean)<=r:
        r=A[i]-mean
        r_output=A[i]
list=[]
list.append(n_output)
list.append(r_output)
list.sort()
list.reverse()
print(list[0],list[1])

Submission status: Wrong Answer

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

enu=max(a)

k=(enu)/2
sa=float("inf")

for i in range(n):
    if abs(k-a[i])<sa and a[i]!=enu:
        sa=k-a[i]
        aru=a[i]

print(enu,aru)

Submission status: Wrong Answer

Solution code:
n=int(input())
A=list(map(int, input().split()))
n_output=max(A)
mean=n_output/2
r=10000000000
r_output=10000000000
for i in range (n):
    if abs(A[i]-mean)<=r:
        r=A[i]-mean
        r_output=A[i]
list=[]
list.append(n_output)
list.append(r_output)
list.sort()
list.reverse()
print(list[0],list[1])

Submission status: Wrong Answer

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

enu=max(a)

k=(enu)/2
sa=float("inf")

for i in range(n):
    if abs(k-a[i])<sa:
        sa=k-a[i]
        aru=a[i]

print(enu,aru)

Submission status: Wrong Answer

Solution code:
n = input()
a = [int(x) for x in input().split()]
max_a = max(a)
print(max_a, min(a, key=lambda x: abs(max_a - x * 2)))

Submission status: Wrong Answer

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

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

    max_a = max(a)
    max_half = max_a / 2

    best_a_j = max_a
    min_d = max_a
    for a_j in a:
        d = abs(a_j - max_half)
        if d < min_d:
            best_a_j = a_j
            min_d = d

    print(max_a, best_a_j)

Submission status: Wrong Answer

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

a1 = A[-1]
a2 = A[N // 2]

print(a1, a2)

Submission status: Wrong Answer

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

max_num=max(a)
middle_num=max_num/2

for i in range(n):
    if a[i]> middle_num:
        num=i
        break

if middle_num-a[i-1]>=middle_num-a[i]:
    print("{} {}".format(max_num,a[i-1]))
else:
    print("{} {}".format(max_num,a[i]))

Submission status: Wrong Answer

Solution code:
import bisect

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

    A.sort()
    n = A[-1]
    i = bisect.bisect_left(A, n / 2)
    if n / 2 - A[i-1] < A[i] - n / 2:
        r = A[i-1]
    else:
        r = A[i]
    print(n, r)

main()

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
a = sorted(a)
import math
res = 100000
ans = 0
for i in range(n):
    if abs((a[-1]/2)-a[i]) <= res:
        ans = i
        res = abs((a[-1]/2)-a[i])
 
print(a[-1],a[ans])

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
a = sorted(a)
import math
res = 100000
ans = 0
for i in range(n):
    if abs((a[-1]/2)-a[i])< res:
        ans = i
        res = abs((a[-1]/2)-a[i])
 
print(a[-1],a[ans])

Submission status: Wrong Answer

Solution code:
def inpl(): return list(map(int, input().split()))
n = int(input())
a = inpl()
maximum = max(a)
c = 0
while True:
    if maximum//2-c in a:
        print(maximum, maximum//2-c)
        break
    elif maximum-maximum//2+c in a:
        print('test')
        print(maximum, maximum-maximum//2+c)
        break
    else:
        c += 1

Submission status: Wrong Answer

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

m = max(a)
print(m, min(a, key=lambda x:abs(m-x*2)))

Submission status: Wrong Answer

Solution code:
import math
n=input()
a=map(int, raw_input().split())
a.sort()
a.reverse()

def comb(N,R):
	return math.factorial(N)/( math.factorial(N-R)*math.factorial(R) )


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

Submission status: Wrong Answer

Solution code:
N = int(raw_input())
a = map(int, raw_input().split())
n = max(a)
if n % 2 == 0:
    med = n/2
    nearest = min([abs(k - med) for k in a])
    if med - nearest in a:
        print(str(n) + " " + str(med - nearest))
    else:
        print(str(n) + " " + str(med + nearest))

else:
    med_1 = (n - 1)/2
    med_2 = (n + 1)/2
    nearest_1 = min([abs(k - med_1) for k in a])
    nearest_2 = min([abs(k - med_2) for k in a])
    if nearest_1 <= nearest_2:
        print(str(n) + " " + str(med_1 - nearest_1))
    else:
        print(str(n) + " " + str(med_2 - nearest_2))

Submission status: Wrong Answer

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

a.sort()

if n == 2:
	print(str(a[1])+" "+str(a[0]))
else:
	maximum = a[-1]
	a.pop()
	half = maximum/2
	a.append(half)
	a.sort()

	position = a.index(half)

	if position+1 >= len(a):
		print(str(maximum)+" "+str(a[position-1]))
		exit()
	else:
		large = a[position+1]
	if position-1 <= 0:
		print(str(maximum)+" "+str(a[position+1]))
		exit()
	else:
		small = a[position-1]

	if large - (half) < (half) - small:
		print(str(maximum)+" "+str(large))
	else:
		print(str(maximum)+" "+str(small))

Submission status: Wrong Answer

Solution code:
# coding : utf-8

import numpy as np

N = int(input())
X = np.array([int(i) for i in input().split()])

X = np.sort(X)
maxl = np.max(X)
Xed = (X - maxl/2)**2
com = X[np.where(Xed == np.min(Xed))]
print(X)
print(Xed)
print(com)
print(maxl,com[0])

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sat Apr 14 22:28:43 2018

@author: mengsayloem
"""
n=int(input())
a=[int(x) for x in input().split()]
a.sort()
m=max(a)
mid=int((m+1)/2)
b={key:abs(mid-key) for key in a}
bb=list(b.keys())
n=min(bb)
print(m,n)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
a = sorted(a)
maxa = max(a)
mid = n//2
print(maxa, a[mid])

Submission status: Wrong Answer

Solution code:
import scipy.misc as scm

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

a = sorted(a, reverse=True)

comb = -1
a_i = a[0]
comb = 0
for i in range(1, n):
    c = scm.comb(a_i, a[i])
    if comb < c:
        comb = c
        a_j = a[i]
    else:
        break
print(a_i, a_j)

Submission status: Wrong Answer

Solution code:
import bisect

n = int(input())
a = [int(i) for i in input().split()]
if n == 2:
    print(a[0], a[1])
else:
    a.sort()
    max_a = a[n-1]
    a.remove(max_a)
    index = bisect.bisect_left(a, max_a // 2)
    if index >= n - 1:
        print(max_a, a[index - 1])
    elif index > 0:
        if max_a // 2 + a[index] == max_a:
            print(max_a, a[index])
        else:
            print(max_a, a[index - 1])
    else:
        print(max_a, a[0])

Submission status: Wrong Answer

Solution code:
import bisect

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

    A.sort()
    n = A[-1]
    i = bisect.bisect(A, n // 2)
    r = A[i]
    print(n, r)

main()

Submission status: Wrong Answer

Solution code:
def abc094D():
    import numpy as np

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

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

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

    if n % 2 == 0:
        r = ai / 2
        b = a.copy() - r
        j = np.argmin(abs(b))
        print(int(ai), int(a[j]))
        return 0
    else:
        r1 = (ai - 1) / 2
        r2 = (ai + 1) / 2
        b1 = a.copy() - r1
        b2 = a.copy() - r2

        j1 = np.argmin(abs(b1))
        j2 = np.argmin(abs(b2))
        # j = np.argmin([abs(a[j1] - r1), abs(r2 - a[j2])])
        if abs(a[j1] - r1) == abs(a[j2] - r2):
            j = np.argmax([nCr(ai, int(a[j1])), nCr(ai, int(a[j2]))])
        else:
            j = np.argmin([abs(a[j1] - r1), abs(r2 - a[j2])])
        aj = [a[j1], a[j2]][j]
        print(int(ai), int(aj))
        return 0


def nCr(n, r):
    """
    Calculate the number of combination (nCr = nPr/r!).
    The parameters need to meet the condition of n >= r >= 0.
    It returns 1 if r == 0, which means there is one pattern
    to choice 0 items out of the number of n.
    """

    # 10C7 = 10C3
    r = min(r, n - r)

    # Calculate the numerator.
    numerator = 1
    for i in range(n, n - r, -1):
        numerator *= i

    # Calculate the denominator. Should use math.factorial?
    denominator = 1
    for i in range(r, 1, -1):
        denominator *= i

    return numerator // denominator


abc094D()

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
a.sort()
a_i = a[-1]
a_i_2 = a_i / 2.0
b = a[0]
max0 = 0

for i in a:
    if i < a_i_2:
        b = i
    elif i != a_i:
        c = i
        break
    else:
        c = b
        break
from scipy.misc import comb
if comb(a_i, b) > comb(a_i,c):
    max0 = comb(a_i, b)
    a_j = b
else:
    max0 = comb(a_i, c)
    a_j = c

b_i = a[-2]
b_i_2 = b_i / 2.0

if n - 10 < 0:
    n_min = 0
else:
    n_min = n - 10

for i in range(n_min,n-1): 
    b_i = a[i]
    b_i_2 = b_i / 2.0
    b = a[0]
    for i in a:
        if i < b_i_2:
            b = i
        elif i != b_i:
            c = i
            break
        else:
            c = b
            break
    if comb(a_i, b) > comb(a_i,c): 
        max1 = comb(b_i, b)
        b_j = b
    else:
        max1 = comb(b_i, c)
        b_j = c
    if max1 > max0:
        max0 = max1
        a_i = b_i
        a_j = b_j
print("{} {}".format(a_i, a_j))

Submission status: Wrong Answer

Solution code:
import sys
n=int(input())
a=sorted(list(map(int,input().split())))
m=a[-1]//2
s=float("inf")
for i in range(n-1):
    if abs(a[-i-1]-m)<s:
        c=a[i]
        s=abs(a[i]-m)
print(a[-1],c)

Submission status: Wrong Answer

Solution code:
from statistics import median


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

if n == 2:
    print(max(a), min(a))
elif sort_a[-1] - medi < sort_a[-2] - medi:
    print(sort_a[-2], medi)
else:
    print(max(a), medi)

Submission status: Wrong Answer

Solution code:
def abc094D():
    import numpy as np

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

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

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

    if n % 2 == 0:
        r = ai / 2
        b = a.copy() - r
        j = np.argmin(abs(b))
        print(int(ai), int(a[j]))
        return 0
    else:
        r1 = (ai - 1) / 2
        r2 = (ai + 1) / 2
        b1 = a.copy() - r1
        b2 = a.copy() - r2

        j1 = np.argmin(abs(b1))
        j2 = np.argmin(abs(b2))
        # j = np.argmin([abs(a[j1] - r1), abs(r2 - a[j2])])
        j = np.argmax([nCr(ai, int(a[j1])), nCr(ai, int(a[j2]))])
        aj = [a[j1], a[j2]][j]
        print(int(ai), int(aj))
        return 0


def nCr(n, r):
    """
    Calculate the number of combination (nCr = nPr/r!).
    The parameters need to meet the condition of n >= r >= 0.
    It returns 1 if r == 0, which means there is one pattern
    to choice 0 items out of the number of n.
    """

    # 10C7 = 10C3
    r = min(r, n - r)

    # Calculate the numerator.
    numerator = 1
    for i in range(n, n - r, -1):
        numerator *= i

    # Calculate the denominator. Should use math.factorial?
    denominator = 1
    for i in range(r, 1, -1):
        denominator *= i

    return numerator // denominator


abc094D()

Submission status: Wrong Answer

Solution code:
import bisect

n = int(input())
a = [int(i) for i in input().split()]
if n == 2:
    print(a[0], a[1])
else:
    a.sort()
    max_a = a[n-1]
    a.remove(max_a)
    index = bisect.bisect_left(a, max_a // 2)
    print(index)
    if index >= n - 1:
        print(max_a, a[index - 1])
    elif index > 0:
        if max_a // 2 + a[index] == max_a:
            print(max_a, a[index])
        else:
            print(max_a, a[index - 1])
    else:
        print(max_a, a[0])

Submission status: Wrong Answer

Solution code:
da = int(input())
ta = list(map(int,input().split()))
import copy
kk = copy.deepcopy(ta)
ta.sort()
a = 0
k = ta[da - 1]

l = k // 2

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

ta.sort()
p = abs(k - ta[0])
for k in range(da):
	if p == kk[k]:
  		a += 1
if a >= 1:
	print(ta[da -1],p)
else:
	print(ta[da -1],ta[0])

Submission status: Wrong Answer

Solution code:
n = int(input())
array = sorted([int(x) for x in input().split()])
tmp = array[-1]
res = array[-1] // 2
point = len(array) // 2

while True:
    if array[point] < tmp:
        tmp = array[point]
        if tmp > res:
            point = (point + len(array)) // 2
        else:
            point = point // 2
    elif tmp == res:
        tmp = res
        break
    else:
        break
if tmp == array[-1]:
    tmp = 0
print(array[-1], tmp)

Submission status: Wrong Answer

Solution code:
import bisect

n = int(input())
a = [int(i) for i in input().split()]
if n == 2:
    print(a[0], a[1])
else:
    a.sort()
    max_a = a[n-1]
    a.remove(max_a)
    index = bisect.bisect_left(a, max_a // 2)
    print(index)
    if index >= n - 1:
        print(max_a, a[index - 1])
    if index > 0:
        if max_a // 2 + a[index] == max_a:
            print(max_a, a[index])
        else:
            print(max_a, a[index - 1])
    else:
        print(max_a, a[0])

Submission status: Wrong Answer

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

a.sort()

if n == 2:
	print(str(a[1])+" "+str(a[0]))
else:
	maximum = a[-1]
	a.pop()
	half = maximum/2
	a.append(half)
	a.sort()

	position = a.index(half)

	large = a[position+1]
	small = a[position-1]

	print(position)
	print(large)
	print(small)

	if large - (half) < (half) - small:
		print(str(maximum)+" "+str(large))
	else:
		print(str(maximum)+" "+str(small))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

n = int(raw_input())
XS = map(int, raw_input().split())

L = []
for i in XS:
    if not i in L:
        L.append(i)
L.sort()
b = (len(L)+1-1) / 2

i = 0
while i < n:
    tmp = b
    BL = XS[:i] + XS[i+1:]
    if (not XS[i] in BL) and L[b] >= XS[i]:
        tmp = b + 1
    print(L[b])
    i = i + 1

Submission status: Wrong Answer

Solution code:
import numpy as np

n = int(input())
a=[int(i) for i in input().split()]
a=sorted(a)
max = a[-1]
del a[-1]
#print(a)
#print(a)
ave = 0
if len(a)==1:
    print("{} {}".format(max, a[0]))
else:
    print("{} {}".format(max, a[np.searchsorted(a,max/2)]))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

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


# solve
# 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):
#     if n == 0 or r == 0: return 1
#     return comb(n, r-1) * (n-r+1) / r


# A = sorted(A)[::-1]
# max_num = 0
# pair = []
# for i in range(len(A)-1):
#     for j in range(i, len(A), 1):
#         if (i == j):
#             continue
#         if (max_num < comb(A[i], A[j])):
#             max_num = comb(A[i], A[j])
#             pair = []
#             pair.append(A[i])
#             pair.append(A[j])

# print(pair[0], pair[1])

print(0, 0)

Submission status: Wrong Answer

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

#2. choose maximum number as a_i and remove
ai = max(a)
a.remove(ai)

# 3. choose the nearest number from (a_i/2) as a_j
abs_dist = [abs(a_temp-(ai/2)) for a_temp in a]
chosen_temp = min(abs_dist)
aj = int(chosen_temp + (ai/2))

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

Submission status: Wrong Answer

Solution code:
n=int(input())
a=[int(x) for x in input().split()]
m=max(a)
n=min(a)
mid=int((m+1)/2)
i=mid
while i>=0:
    if i in a:
        print(m,i)
        break
    i-=1
if i==0:
    while i<=m:
        if i in a:
            print(m,i)
            break
    i+=1

Submission status: Wrong Answer

Solution code:
import scipy.misc as scm

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

a = sorted(a, reverse=True)

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

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
a.sort()
a_i = a[-1]
a_i_2 = a_i / 2.0
b = a[0]

for i in a:
    if i < a_i_2:
        b = i
    elif i != a_i:
        c = i
        break
    else:
        c = b
        break
from scipy.misc import comb
if comb(a_i, b) > comb(a_i,c):
    max1 = comb(a_i, b)
    a_j = b
else:
    max1 = comb(a_i, c)
    a_j = c

import numpy as np
def getNearestValue(list0, num):
    """
    概要: リストからある値に最も近い値を返却する関数
    @param list: データ配列
    @param num: 対象値
    @return 対象値に最も近い値
    """

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

if n - 10 < 0:
    n_min = 0
else:
    n_min = n - 10

for i in range(n_min,n): 
    b_j = getNearestValue(a, a[i]/2.0)
    b1 = comb(a[i], b_j)
    if max1 < b1 and a[i] > b_j:
        max1 = b1
        a_i = a[i]
        a_j = b_j
print("{} {}".format(a_i, a_j))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
a = sorted(a)
import math
res = 10000
ans = 0
for i in range(n):
    if abs((a[-1]/2)-a[i])< res:
        ans = i
        res = abs((a[-1]/2)-a[i])

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

Submission status: Wrong Answer

Solution code:
import bisect

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

    A.sort()
    n = A[-1]
    i = bisect.bisect_left(A, n // 2)
    r = A[i]
    print(n, r)

main()

Submission status: Wrong Answer

Solution code:
import numpy as np

n = int(input())
a=[int(i) for i in input().split()]
a=sorted(a)
#print(a)
ave = 0

print("{} {}".format(a[-1], a[np.searchsorted(a,a[-1]/2)]))

Submission status: Wrong Answer

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

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

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

    if n % 2 == 0:
        r = ai / 2
        b = a.copy() - r
        j = np.argmin(abs(b))
        print(int(ai), int(a[j]))
        return 0
    else:
        r1 = (ai - 1) / 2
        r2 = (ai + 1) / 2
        b1 = a.copy() - r1
        b2 = a.copy() - r2

        j1 = np.argmin(abs(b1))
        j2 = np.argmin(abs(b2))
        j = np.argmin([abs(a[j1] - r1), abs(r2 - a[j2])])
        aj = [a[j1], a[j2]][j]
        print(int(ai), int(aj))
        return 0


abc094D()

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
	n = int(input())
	a = [int(x) for x in input().split(' ')]

	sa = sorted(a)

	j = -1
	for i in range(n):
		tn = sa[-i]
		tr = sa[0]
		om = tr * (tn - tr)
		for j in range(1, n-1):
			tr = sa[j]
			tm = tr * (tn - tr)
			if om <= tm:
				break
			else:
				om = tm
		break

	print('{} {}'.format(sa[n-1], sa[j-1]))

Submission status: Wrong Answer

Solution code:
n = int(input())
A = [int(a) for a in input().split()]
M = max(A)
A.remove(max(A))
i,j = 0,0
if M % 2 == 1:
    while i >= 0:
        if ((M - 1) // 2) + i in A:
            print(M,((M - 1) // 2) + i)
            quit()

        elif ((max(A) - 1) // 2) - i in A:
            print(M, ((M - 1) // 2) - i)
            quit()

        i += 1

else:
    while j >= 0:
        if (M // 2) + j in A:
            print(M,(M // 2) + j)
            quit()

        elif (M // 2) - j in A:
            print(M,(M // 2) - j)
            quit()

        j += 1

Submission status: Wrong Answer

Solution code:
import math

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

max_num=max(a)
middle_num=math.ceil(max_num/2)
middle_num_up=middle_num
middle_num_down=middle_num

if n>2:
    for i in range(n):
        if middle_num_up or middle_num_down in a:
            ans=middle_num
            break
        else:
            middle_num_up+=1
            middle_num_down-=1
else:
    ans=min(a)

print("{} {}".format(max_num,ans))

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

Solution code:
import math

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

max_num=max(a)
middle_num=math.ceil(max_num/2)
middle_num_up=middle_num
middle_num_down=middle_num

if n>2:
    for i in range(n):
        if middle_num_up or middle_num_down in a:
            ans=middle_num
        else:
            middle_num_up+=1
            middle_num_down-=1
else:
    ans=min(a)

print("{} {}".format(max_num,ans))