Problem:


Score : 300 points

Problem Statement

When l is an odd number, the median of l numbers a_1, a_2, ..., a_l is the (\frac{l+1}{2})-th largest value among a_1, a_2, ..., a_l.

You are given N numbers X_1, X_2, ..., X_N, where N is an even number.
For each i = 1, 2, ..., N, let the median of X_1, X_2, ..., X_N excluding X_i, that is, the median of X_1, X_2, ..., X_{i-1}, X_{i+1}, ..., X_N be B_i.

Find B_i for each i = 1, 2, ..., N.

Constraints

2 \leq N \leq 200000

N is even.

1 \leq X_i \leq 10^9

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N
X_1 X_2 ... X_N

Output

Print N lines.
The i-th line should contain B_i.

Sample Input 1

4
2 4 4 3

Sample Output 1

4
3
3
4

Since the median of X_2, X_3, X_4 is 4, B_1 = 4.

Since the median of X_1, X_3, X_4 is 3, B_2 = 3.

Since the median of X_1, X_2, X_4 is 3, B_3 = 3.

Since the median of X_1, X_2, X_3 is 4, B_4 = 4.

Sample Input 2

2
1 2

Sample Output 2

2
1

Sample Input 3

6
5 5 4 4 3 3

Sample Output 3

4
4
4
4
4
4



Sample input:
4
2 4 4 3


Sample output:
4
3
3
4

Submission status: Time Limit Exceeded

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

def main():
    N = int(input())
    x_list = list(map(int, input().split()))
    x_sort = x_list[:]
    x_sort.sort()
    med = (N // 2) -1
    threshold = x_sort[med]
    med_dict = {}

    for i in range(N):
        if x_list[i] in med_dict:
            print(med_dict[x_list[i]])
        elif x_list[i] > threshold:
            print(threshold)
        else:
            removed_x_list = x_list[:]
            removed_x_list.remove(x_list[i])
            removed_x_list.sort()
            median = removed_x_list[med]
            med_dict[x_list[i]] = median
            print(median)
    
if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

def main():
    N = int(input())
    x_list = list(map(int, input().split()))
    med_dict = {}

    med = (N // 2) -1

    for i in x_list:
        if i in med_dict:
            print(med_dict[i])
        else:
            removed_x_list = x_list[:]
            removed_x_list.remove(i)
            removed_x_list.sort()
            median = removed_x_list[med]
            med_dict[i] = median
            print(median)
    #print(med_dict)

    
if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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


for i in range(N):
    d = X.pop(i)
    new = sorted(X)
    print(new.pop(int(N/2-1)))
    X.insert(i,d)

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
X=list(map(int,input().split()))
for i in range(N):
    X_list=X[:i]+X[i+1:]
    X_list.sort()
    print(X_list[int(N/2-1)])

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
X=list(map(int,input().split()))
for i in range(N):
    idx=i+1
    X_list=X[:idx-1]+X[idx:]
    X_list.sort()
    print(X_list[int(N/2-1)])

Submission status: Time Limit Exceeded

Solution code:
# your code goes here
import copy
n=int(input())
l = list(map(int,input().split()))

a = sorted(l)
b = copy.deepcopy(a)
r = int(n/2)
for i in range(0,n):
	a.remove(l[i])
	print(a[r-1])
	a = copy.deepcopy(b)

Submission status: Time Limit Exceeded

Solution code:
import copy
n=int(input())
l = list(map(int,input().split()))

a = sorted(l)

r = int(n/2)

for i in range(0,n):
	a.remove(l[i])
	print(a[r-1])

	
	a = sorted(l)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
x=list(map(int,input().split()))
import statistics
for i in range(n):
    y=x[i]
    x.pop(i)
    print(statistics.median(x))
    x.insert(i,y)

Submission status: Time Limit Exceeded

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

for i in x:
    p=a.index(i)

    if p< n//2:
        print(a[n//2])
    else:
        print(a[n//2-1])

Submission status: Time Limit Exceeded

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

for i in range(N):
	Xi = list(X)
	Xi.pop(i)
	Xi.sort()
	Xi.reverse()
	num = int((len(Xi)-1)/2)
	print(Xi[num])

Submission status: Time Limit Exceeded

Solution code:
import copy
N = int(input())
X = list(map(int, input().split()))

for i in range(N):
    tmp = copy.deepcopy(X)
    tmp.pop(i)
    tmp.sort()
    print(tmp[(len(tmp)+1)//2-1])

Submission status: Time Limit Exceeded

Solution code:
import copy
N = int(input())
X = list(map(int, input().split()))

for i in range(N):
    tmp = copy.deepcopy(X)
    tmp.pop(i)
    tmp.sort()
    if len(tmp)%2 == 0:
        print(tmp[len(tmp)//2-1])
    else:
        print(tmp[(len(tmp)+1)//2-1])

Submission status: Time Limit Exceeded

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

numbers = []
for j in range(N):
    for i in range(N):
        numbers.append(X[i])
    tmp = X[j]
    numbers.remove(tmp)
    numbers.sort()
    print(numbers[int(N/2)-1])
    numbers.clear()

Submission status: Time Limit Exceeded

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

def get_median(ar):
    # assume always odd length
    n = len(ar)
    med_index = n//2
    return ar[med_index]

for i in range(N):
    subset = X[:i] + X[i+1:]
    subset.sort()
    print(get_median(subset))

Submission status: Time Limit Exceeded

Solution code:
from statistics import median
N = int(input())
X = list(map(int, input().split()))

for i in range(N):
    print(median(X[:i]+X[i+1:]))

Submission status: Time Limit Exceeded

Solution code:
def find_medians(x, num):
	temp_X = list(x)
	del temp_X[num]
	temp_X.sort()
	return temp_X[int( (len(temp_X)  + 1 ) / 2 - 1)]

N = int(input())
X = list(map(int, input().split()))
for i in range(N):
	print(find_medians(X, i))

Submission status: Time Limit Exceeded

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

for i in range(0,n):
    current = nums[0:n]
    current.pop(i)
    current.sort(key=int , reverse = True)
    print(current[ int(n / 2  - 1)])

Submission status: Time Limit Exceeded

Solution code:
import copy
n = int(input())
nums= list(map(int, input().split()))

for i in range(0,n):
    current = copy.deepcopy(nums)
    current.pop(i)
    current.sort(key=int , reverse = True)
    print(current[ int(n / 2  - 1)])

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
X = list(map(int, input().split( )))
for l in range(N):
    Y = X[ : ]
    del Y[l]
    Y.sort( )
    l = N//2-1
    print(Y[l])

Submission status: Time Limit Exceeded

Solution code:
import copy
N=int(input())
X=list(map(int,input().split()))
Y=copy.deepcopy(X)

Z=N//2
for i in range(N):
    
    Y.pop(i)

    Y.sort()
    
    print(Y[Z-1])
    Y=copy.deepcopy(X)

Submission status: Time Limit Exceeded

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

sortedX = X[:]
sortedX.sort()
lenX = len(X)

for i in X:
    if sortedX.index(i) > int(lenX/2) - 1:
        print(sortedX[int(lenX/2)-1])
    else:
        print(sortedX[int(lenX/2)])

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

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

arrayX = np.array(X)
num = arrayX.size

for i in range(num):
    arrayX = np.delete(arrayX,i)
    print(int(np.median(arrayX)))
    arrayX = np.array(X)

Submission status: Time Limit Exceeded

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

for i in range(n):
    z = y.copy()
    z.remove(x[i])
    print(z[n//2 -1])

Submission status: Time Limit Exceeded

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

for i in range(n):
    y = x.copy()
    del y[i]
    print(sorted(y)[n//2 -1])

Submission status: Time Limit Exceeded

Solution code:
import math
import sys

def getinputdata():

    # 配列初期化
    array_result = []    
    data = input()
    array_result.append(data.split(" "))

    flg = True

    try:
        while flg:

            data = input()

            array_temp = []

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = True

            else:

                flg = False
    finally:

        return array_result

arr_data = getinputdata()

n = int(arr_data[0][0])

val = (n-1) // 2

arr = list(map(int, arr_data[1]))

arr_sort = sorted(arr)

for v in arr:

    i = arr_sort.index(v)
    
    arr01 = arr_sort[:i] + arr_sort[i + 1:]
    
    print(arr01[val])

Submission status: Time Limit Exceeded

Solution code:
import math
import sys

def getinputdata():

    # 配列初期化
    array_result = []    
    data = input()
    array_result.append(data.split(" "))

    flg = True

    try:
        while flg:

            data = input()

            array_temp = []

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = True

            else:

                flg = False
    finally:

        return array_result

arr_data = getinputdata()

n = int(arr_data[0][0])

val = (n-1) // 2

arr = list(map(int, arr_data[1]))


for i in range(0, len(arr)):
    
    arr01=sorted(arr[:i]+arr[i+1:])
    
    print(arr01[val])

Submission status: Time Limit Exceeded

Solution code:
import copy
from statistics import median

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

y = copy.deepcopy(x)
for a in x:
    y.remove(a)
    print(median(y))
    y.append(a)

Submission status: Time Limit Exceeded

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

while True:
    list = sorted(x)
    list.remove(x[a])

    print(list[(len(n) - 2)//2])
    a += 1
    if a == len(n):
        break

Submission status: Time Limit Exceeded

Solution code:
n = [n for n in range(int(input()))]
x = [int(a) for a in map(int, input().split())]
a = 0

while True:
    list = sorted(x)
    list.remove(x[a])

    print(list[(len(n) - 2)//2])
    a += 1
    if a == len(n):
        break

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
n_l = [n for n in range(n)]
x = [int(a) for a in map(int, input().split())]
a = 0

while True:
    list = sorted(x)
    list.remove(x[a])

    print(list[(n - 2)//2])
    a += 1
    if a == n:
        break

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
n_l = [n for n in range(n)]
x = [int(a) for a in map(int, input().split())]
a = 0
list = []

while True:
    for i in range(len(x)):
        if i == a:
            pass
        else:
            list.append(x[i])

    list.sort()

    print(list[(n - 2)//2])

    a += 1
    list = []

    if a == n:
        break

Submission status: Time Limit Exceeded

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

for i in range(N):
    x = X[:]
    x.pop(i)
    x.sort()
    print(x[(N-1)//2])

Submission status: Time Limit Exceeded

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

for i in range(n):
    b=x.pop(i)
    print(sorted(x)[int(n/2)-1])
    #print(a[int(n/2)-1])
    x.insert(i,b)

Submission status: Time Limit Exceeded

Solution code:
def quick_sort(arr):
    left = []
    right = []
    if len(arr) <= 1:
        return arr
    ref = arr[0]
    ref_count = 0

    for ele in arr:
        if ele < ref:
            left.append(ele)
        elif ele > ref:
            right.append(ele)
        else:
            ref_count += 1
    left = quick_sort(left)
    right = quick_sort(right)
    return left + [ref] * ref_count + right

n = int(input())
l = input().split()
x = [int(s) for s in l]
for i in range(n):
    y = list(x)
    y.pop(i)
    z = quick_sort(y)
    print(z[int((n/2) - 1)])

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
l = input().split()
x = [int(s) for s in l]
for i in range(n):
    y = list(x)
    y.pop(i)
    y.sort()
    print(y[int((n/2) - 1)])

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
Xn = list(map(int,input().split()))
import numpy as np

for i in range(N):
    Xn_numpy = np.array(Xn)
    Xn_deleted = np.delete(Xn_numpy, i)
    Xn_sort = np.sort(Xn_deleted)[::-1]
    a = (len(Xn_sort)+1)//2-1
    print(Xn_sort[a])

Submission status: Time Limit Exceeded

Solution code:
import copy

N = int(input())
a = list(map(int, input().split(' ')))
for i in range(len(a)):
    _a = copy.copy(a)
    _a.pop(i)
    _a.sort()
    index =int((len(a) + 1) / 2 - 1)
    print(_a[index])

Submission status: Time Limit Exceeded

Solution code:
#Many Medians

#ライブラリ
import copy

#入力
N = int(input())
X = list(map(int, input().split()))
ans = []

for i in range(len(X)):
	temp = copy.copy(X)
	temp.pop(i)
	temp.sort()
	print((temp[int((len(temp)+1)/2-1)]))

Submission status: Time Limit Exceeded

Solution code:
#Many Medians

#ライブラリ
import copy

#入力
N = int(input())
X = list(map(int, input().split()))
ans = []

for i in range(len(X)):
	temp = copy.copy(X)
	temp.pop(i)
	temp.sort()
	ans.append(temp[int((len(temp)+1)/2-1)])

#出力
for j in range(len(ans)):
	print(ans[j])

Submission status: Time Limit Exceeded

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


    for i in range(0, n):
        sort_list = x[:]
        sort_list.pop(i)
        sort_list.sort()
        print(sort_list[n//2-1])

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
a = input()
a = int(a)
b = input()
b= b.rstrip().split(" ")

#print(b)
for j in range(len(b)):
    b1=[]
    for i in range(len(b)):
        if j ==i:
            i +=1
        else:
            b1.append(int(b[i]))
            i +=1
    b1 = sorted(b1)
    print(b1[int(a/2)-1])

Submission status: Time Limit Exceeded

Solution code:
a = input()
a = int(a)
b = input()
b= b.rstrip().split(" ")

#print(b)

b1=[]
for i in range(len(b)):
    b1.append(int(b[i]))
    i +=1
    
#print(b1)

list2=[]
for j in range(len(b1)):
    list1=[]
    for k in range(len(b1)):
        if j == k :
            k +=1
        else:
            list1.append(b1[k])
            k+=1
    list3=sorted(list1)
    list2.append(list3)
    j +=1
#print(list2)

for l in range(int(a)):
    print(list2[l][int(a/2)-1])
    l+=1

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
X = list(map(int, input().split()))
Y = X.copy()
Y.sort()

for i in X:
    if Y.index(i) >= N//2:
        print(Y[N//2-1])
    if Y.index(i) <= N//2 - 1:
        print(Y[N//2])

Submission status: Time Limit Exceeded

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

for i in range(n):
    b = list(a)
    del b[i]
    b.sort()
    print(b[int((n - 1) / 2)])

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = list(map(int, input().split()))
import numpy as np
for i in range(n):
    print(int(np.median(a[0:i] + a[i+1:])))

Submission status: Time Limit Exceeded

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

for i,j in zip(x,range(n)):
    x.remove(i)
    t = sorted(x)
    print(t[int(n/2-1)])
    x.insert(j,i)

Submission status: Time Limit Exceeded

Solution code:
def solve():
    N = int(input())
    X = list(map(int, input().split()))
    
    for i in range(N):
        l = X[:i] + X[i+1:]
        l.sort()
        print(l[N//2-1])

if __name__ == '__main__':
    solve()

Submission status: Time Limit Exceeded

Solution code:
import statistics

def solve():
    N = int(input())
    X = list(map(int, input().split()))
    
    for i in range(N):
        l = X[:i] + X[i+1:]
        print(statistics.median(l))

if __name__ == '__main__':
    solve()

Submission status: Time Limit Exceeded

Solution code:
import statistics
N = int(input())
X = list(map(int, input().split()))

for i in range(N):
    l = X[:i] + X[i+1:]
    print(statistics.median(l))

Submission status: Time Limit Exceeded

Solution code:
from statistics import median

N = int(input())
data = list(map(int, input().split(' ')))

for i in range(len(data)):
    temp = [x for j,x in enumerate(data) if j != i]
    print(median(temp))

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
X = [int(i) for i in input().split()]
for i in range(N): print((lambda j: sorted([x for k, x in enumerate(X) if not k == j]))(i)[N//2-1])

Submission status: Time Limit Exceeded

Solution code:
import numpy as np

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

tmp = np.zeros(n)
tmp = list(x)
indexhold = np.argsort(tmp)
for i in range(n):
    for j in range(n):
        if i == indexhold[j] and j < n/2:
            print(tmp[indexhold[int(n/2)]])
        elif i == indexhold[j] and j >= n/2:
            print(tmp[indexhold[int(n/2) -1]])

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
x = [int(i) for i in input().split()]
for i in range(n):
    tmp = list(x)
    tmp[i] *= -1
    tmp.sort()
    median = int(n/2)
    print(tmp[median])

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
X = list(map(int,input().split()))
medIndex=int((n-1)/2)
for i in range(n) :
  Y = X[:]
  Y.pop(i)
  Y.sort()
  print(Y[medIndex])

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
X = list(map(int,input().split()))
for i in range(n) :
  Y = X[:]
  Y.pop(i)
  Y.sort()
  medIndex = int((n-1)/2)
  print(Y[medIndex])

Submission status: Time Limit Exceeded

Solution code:
import copy
N = int(input())
numList = list(map(int, input().split()))
medIndex = int((N-1)/2)

for i in range(0,N):
	numListCopy = copy.deepcopy(numList)
	numListCopy.pop(i)
	numListCopy = sorted(numListCopy)
	print(numListCopy[medIndex])

Submission status: Time Limit Exceeded

Solution code:
import copy
N = int(input())
numList = list(map(int, input().split()))
medIndex = int((N-1)/2)

for i in range(0,N):
	numListCopy = copy.deepcopy(numList)
	numListCopy.pop(i)
	numListCopy.sort()
	print(numListCopy[medIndex])

Submission status: Time Limit Exceeded

Solution code:
import copy
N = int(input())
numList = list(map(int, input().split()))

for i in range(0,N):
	numListCopy = copy.deepcopy(numList)
	numListCopy.pop(i)
	numListCopy.sort()
	medIndex = int(len(numListCopy)/2)
	print(numListCopy[medIndex])

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
x = list(map(int, input().split()))
a = map(lambda x: x[(n-1)//2], [sorted(x[:i] + x[i+1:]) for i in range(n)])
for i in a:
  print(i)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
xlist = [int(x) for x in input().split()]
sxlist = sorted(xlist)
for i in range(n):
    if sxlist.index(xlist[i]) < n/2:
        print(sxlist[int(n/2)])
    else:
        print(sxlist[int(n/2)-1])

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
xlist = [int(x) for x in input().split()]
sxlist = sorted(xlist)
for i in range(n):
    index = sxlist.index(xlist[i])
    if index < n/2:
        print(sxlist[int(n/2)])
    else:
        print(sxlist[int(n/2)-1])

Submission status: Time Limit Exceeded

Solution code:
def get_values():
    return [int(a) for a in input().split()]

N, = get_values()
Xs = get_values()

for idx, xi in enumerate(Xs):
    Ys = sorted(Xs[:idx] + Xs[idx+1:])
    print(Ys[len(Ys) // 2])

Submission status: Time Limit Exceeded

Solution code:
from statistics import median

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

for i in range(n):
    x_median = x[0:i] + x[i+1:]
    print(median(x_median))

Submission status: Time Limit Exceeded

Solution code:
#ABC 094 Many Medians

numbers=int(input())
list_num=[int(i) for i in input().split()]
sorted_list=sorted(list_num)

median1=sorted_list[int(numbers/2)-1]
median2=sorted_list[int(numbers/2)]

for i in list_num:
    if sorted_list.index(i) <= numbers/2-1:
        print(median2)
    else:
        print(median1)

Submission status: Time Limit Exceeded

Solution code:
# N = 4
N = int(input())
# X = [2, 4, 4, 3]
X = list(map(int, input().split(' ')))

# def get_median(l):
#     return median(l)

for i in range(N):
    target_l = X[:i] + X[i+1:]
    target_l = sorted(target_l)
    print(target_l[int((N-1)/2)])

Submission status: Time Limit Exceeded

Solution code:
from statistics import median

N = int(input())
X = list(map(int, input().split(' ')))

def get_median(l):
    return median(l)

for i in range(N):
    target_l = X[:i] + X[i+1:]
    print(median(target_l))

Submission status: Time Limit Exceeded

Solution code:
def find_medians(N, X):
    result = []

    for i in range(1, N + 1):
        S = X.copy()
        S.pop(i - 1)
        S.sort()
        m = int((len(S) + 1)/2) - 1
        result.append(S[m])

    return result


if __name__ == "__main__":
    N = int(input().rstrip())
    X = list(map(int, input().rstrip().split(" ")))
    B = find_medians(N, X)

    for b in B:
        print(b)

Submission status: Time Limit Exceeded

Solution code:
import copy 

N = int(input())
X_list = list(map(int, input().split()))
X_sorted_list = sorted(X_list)

for i in range(N):
    current_list = copy.deepcopy(X_sorted_list)
    current_list.remove(X_list[i])
    median = current_list[-(N//2)]
    print(median)

Submission status: Time Limit Exceeded

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

for i in range(N):
    current_list = X_list[:i] + X_list[i+1:]
    current_list.sort()
    median = current_list[-(N//2)]
    print(median)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
A = list(map(int, input().split()))
X = int(N/2-1)
for i in range(0,N):
  K = A[i]
  del A[i]
  B = sorted(A)
  print(B[X])
  A.insert(i,K)

Submission status: Time Limit Exceeded

Solution code:
import copy
N = int(input())
A = list(map(int, input().split()))
X = int(N/2-1)
moto = copy.deepcopy(A)
A.sort()
sort_A = copy.deepcopy(A)
for i in range(0,N):
  A.remove(moto[i])
  print(A[X])
  A = copy.deepcopy(sort_A)

Submission status: Time Limit Exceeded

Solution code:
import copy
N = int(input())
A = list(map(int, input().split()))
X = int(N/2-1)
moto = copy.deepcopy(A)
for i in range(0,N):
  del A[i]
  A.sort()
  print(A[X])
  A = copy.deepcopy(moto)

Submission status: Time Limit Exceeded

Solution code:
from statistics import median

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

for i in range(N):
  tmp_X = [X[j] for j in range(N) if j != i]
  #print(tmp_X)
  print(median(tmp_X))

Submission status: Time Limit Exceeded

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

for i in range(n):
    a = x[:]
    del a[i]
    a.sort()
    print(a[int(n/2)-1])

Submission status: Time Limit Exceeded

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

for i in range(n):
    a = x[:]
    del a[i]
    a.sort()
    print(a[int((len(a)+1)/2)-1])

Submission status: Time Limit Exceeded

Solution code:


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

    nums = sorted(X)
    center = len(nums)//2
    if len(nums)%2 == 0:
        is_even = True
    else:
        is_even = False

    for x in X:
        i = nums.index(x)
        if i < center:
            if is_even:
                print(nums[center])
            else:
                print(nums[center+1])
        else:
            if is_even:
                print(nums[center-1])
            else:
                print(nums[center+1])


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
from statistics import median

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

for i in range(0, len(x)):
    x_copy = x[:]
    x_copy.pop(i)
    print(median(x_copy))

Submission status: Time Limit Exceeded

Solution code:


def main():
    N = int(input())

    X = list(map(int, input().split(" ")))

    for i in range(len(X)):
        x = X[:i] + X[i+1:]
        x = sorted(x)

        print(x[len(x)//2])


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
x = input().split(" ")
b_x = [i for i in range(n)]
c = list(zip(map(int, x), b_x))
c.sort()
x, b_x = zip(*c)
for i in range(n):
    if b_x.index(i) < n//2:
            print(x[n//2])
    else:
            print(x[n//2-1])

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
x = input().split(" ")
b_x = [0 for i in range(n)]
for i in range(n):
    x[i] = [int(x[i]), i]
x.sort()
for i in range(n):
    b_x[i] = x[i][1]
for i in range(n):
    if b_x.index(i) < n//2:
            print(x[n//2][0])
    else:
            print(x[n//2-1][0])

Submission status: Time Limit Exceeded

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

for i in range(len(X)):
    Y = X[:i] + X[i+1:]
    Y.sort()
    print(Y[int(N/2)-1])

Submission status: Time Limit Exceeded

Solution code:
import copy
N = int(input())
X = list(map(int,input().split()))
Y = copy.deepcopy(X)
for i in range(N):
  del Y[i]
  Y.sort()
  print(Y[(N-1)//2])
  Y = copy.deepcopy(X)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = list(map(int, input().split(' ')))
i = 0
for i in range(n):
    ai = a[0:i] + a[i+1:n]
    aisrt = sorted(ai)
    l = int(len(aisrt)/2)
    print(aisrt[l])

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
arr=[int(x) for x in input().split()]
for i in range(n):
    a = arr[:i] + arr[i+1:]
    a.sort()
    index = int((n-1)/2)
    print(a[index])

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
x=list(map(lambda x:int(x), input().split()))
mi = int(n/2)-1
sx=x[:]
sx.sort()
for item in x:
    cx=sx[:]
    cx.remove(item)
    print(cx[mi])

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
x=list(map(lambda x:int(x), input().split()))
mi = int(n/2)-1
for i in range(n):
    cx = x[:]
    del	cx[i]
    cx.sort()
    print(cx[mi])

Submission status: Time Limit Exceeded

Solution code:
#abc094c
from statistics import median

n=int(input())
x=list(map(int,input().split()))
res=[]
for i in range(n):
 y=x.copy()
 y.pop(i)
 res.append(median(y))
for i in range(n):
 print(res[i])

Submission status: Time Limit Exceeded

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

for i, num in enumerate(x):
    x_copy = x.copy()
    x_copy.pop(i)
    x_copy = sorted(x_copy)
    print(x_copy[len(x_copy) // 2])

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
X_list = list(map(int, input().split()))
idx_value = []

for idx, v in enumerate(X_list, 1):
    idx_value.append((idx, v,))

i_list = [i for i in range(1, N + 1)]
idx_value_copy = idx_value.copy()
idx_value_copy.sort(key=lambda x: x[1])
li_list = []
for t in idx_value:
    for idx, t_c in enumerate(idx_value_copy, 1):
        if t_c[0] == t[0] and t_c[1] == t[1]:
            li_list.append(idx)
            break

median_idx = int(N / 2)
median_left = idx_value_copy[median_idx - 1][1]
median_right = idx_value_copy[median_idx][1]
for i in li_list:
    if i <= median_idx:
        print(median_right)
    else:
        print(median_left)

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Tue Apr 17 14:45:17 2018

@author: kitamura
"""

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

for i in range(N):
    M=[]
    for j in range(N):
        if j==i:
            continue
        M.append(X[j])
    M.sort()
#    print(M)
    print(M[(int(N/2))-1])

Submission status: Time Limit Exceeded

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

#for i in N:
#    for n in range(len(X)):
#        if n==i:
#            pass
#        else:
#            Sum+=X
#
#Sum=Sum/(N-1)
#
#for j in X:
#    if()
for i in range(N):
    M=[]
    SUM=0
    for j in range(N):
        if j==i:
            continue
        M.append(X[j])
        SUM+=X[j]
    SUM=SUM//(N-1)
    if SUM==min(M) and len(M)!=1:
        SUM+=1
    if int(SUM) not in M:
        while int(SUM) not in M:
            SUM+=1
    print(SUM)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
X = list(map(int, input().split()))
Y = [[X[k],k] for k in range(N)]
Z = Y.copy()
Z.sort()

A = [0 for k in range(N)]

for k in range(N):
    A[Z[k][1]] = (Z[:Y[k][1]]+Z[Y[k][1]+1:])[N//2-1][0]

for x in A:
    print(x)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
X = list(map(int, input().split()))
Y = [[X[k],k] for k in range(N)]
Z = sorted(Y)
A = [0 for k in range(N)]

for k in range(N):
    A[Z[k][1]] = (Z[:Y[k][1]]+Z[Y[k][1]+1:])[N//2-1][0]

for x in A:
    print(x)

Submission status: Time Limit Exceeded

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

for k in range(N):
    print(sorted(X[:k]+X[k+1:])[N//2-1])

Submission status: Time Limit Exceeded

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

for i in range(N):
    X=X_raw[:]
#    X.pop(i)
    del X[i]
    X.sort()
    print(X[int(N/2-1)])

Submission status: Time Limit Exceeded

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

for i in range(N):
    X=X_raw[:]
    X.pop(i)
    X.sort()
    print(X[int(N/2-1)])

Submission status: Time Limit Exceeded

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

for i in range(n):
    tmp = x.copy()
    tmp.pop(i)
    tmp.sort()
    print(tmp[n//2-1])

Submission status: Time Limit Exceeded

Solution code:
import sys
import numpy as np

N=int(input())

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

for i in range(N):
	temp=X
	temp=np.delete(temp,i)
	med=np.median(temp)
	print(int(med))

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8
# Your code here!
length = int(raw_input())
li = list(map(int,raw_input().split()))
for i in range(length):
    part_li = li[:i]+li[i+1:]
    part_li = sorted(part_li)
    print part_li[length/2-1]

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
X = list(map(int,input().split()))
sX = sorted(X)
tsX = sX[:]
k = int(N/2-1)
for i in range(N):
    tsX.remove(X[i])
    print(tsX[k])
    tsX = sX[:]

Submission status: Time Limit Exceeded

Solution code:

n = int(input())
x_str = input().split()
x = [int(c) for c in x_str]

x_len = len(x)
center = (x_len - 1)//2

c_x = x[:]
c_x.sort()

for i in range(x_len):
    cc_x = c_x[:]
    cc_x.remove(x[i])
    print(cc_x[center])

Submission status: Time Limit Exceeded

Solution code:

n = int(input())
x_str = input().split()
x = [int(c) for c in x_str]

l_ = len(x) - 1

for i in range(len(x)):
    copy_x = x[:]
    copy_x.pop(i)
    copy_x.sort()
    print(copy_x[(l_)//2])

Submission status: Time Limit Exceeded

Solution code:

def qsort(list):
    if list == []:
        return []
    else:
        p = list[0]
        left = [x for x in list[1:] if x < p]
        right = [x for x in list[1:] if x >= p]
        return qsort(left) + [p] + qsort(right)


n = int(input())
x_str = input()
x_str_list = x_str.split()
x = [int(c) for c in x_str_list]

l_ = len(x) - 1

for i in range(len(x)):
    copy_x = x[:]
    copy_x.pop(i)
    copy_x = qsort(copy_x)
    print(copy_x[(l_)//2])

Submission status: Time Limit Exceeded

Solution code:
if __name__ == '__main__':
    N = int(input())
    X = list(map(int, input().split()))
    x = sorted(X[:])
    for i in range(N):
        _x = x[:]
        _x.remove(X[i])
        print(_x[int(N/2-1)])

Submission status: Time Limit Exceeded

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

    for i in range(N):
        x = X[:]
        x.pop(i)
        x.sort()
        print(x[int(N/2-1)])