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: Wrong Answer

Solution code:
import numpy as np
import copy

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

for x in xs:
    ind = sort_xs.index(x)
    new_sort_xs = copy.deepcopy(sort_xs)
    del new_sort_xs[ind]
    print(new_sort_xs)
    if ind > (n/2) + 1:
        print(new_sort_xs[int(n/2)])
    else:
        print(new_sort_xs[int(n/2)-1])

Submission status: Wrong Answer

Solution code:
import numpy as np
import copy

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

for x in xs:
    ind = sort_xs.index(x)
    new_sort_xs = copy.deepcopy(sort_xs)
    del new_sort_xs[ind]
    print(new_sort_xs)
    print("---")
    if ind > (n/2) + 1:
        print(new_sort_xs[int(n/2)])
    else:
        print(new_sort_xs[int(n/2)-1])

Submission status: Wrong Answer

Solution code:
n=int(input())
x=sorted(list(map(int,input().split())))
N = int(n/2)
x1, x2 = x[N-1], x[N]
for i in range(n):
    if x[i]<=x1:
        print(x2)
    else:
        print(x1)

Submission status: Wrong Answer

Solution code:
n=int(input())
x=list(map(int,input().split()))
y = sorted(x)
N = int(n/2)
x1, x2 = x[N-1], x[N]
for i in range(n):
    if x[i]<=x1:
        print(x2)
    else:
        print(x1)

Submission status: Wrong Answer

Solution code:
n=int(input())
x=sorted(list(map(int,input().split())))
N = int(n/2)
x1, x2 = x[N-1], x[N]
for i, xx in enumerate(x):
    if xx<=x1:
        print(x2)
    else:
        print(x1)

Submission status: Wrong Answer

Solution code:
n=int(input())
x=sorted(map(int,input().split()))
N = int(n/2)
x1, x2 = x[N-1], x[N]
for i, xx in enumerate(x):
    if xx<=x1:
        print(x2)
    else:
        print(x1)

Submission status: Wrong Answer

Solution code:
n=int(input())
x=sorted(map(int,input().split()))
x1, x2 = x[n//2-1], x[n//2]
for i, xx in enumerate(x):
    if xx<=x1:
        print(x2)
    else:
        print(x1)

Submission status: Wrong Answer

Solution code:
n = int(input())
x = sorted(list(map(int, input().split())))
x1 = x[n//2-1]
x2 = x[n//2]
for i, xx in enumerate(x):
    if xx <= x1:
        print(x2)
    else:
        print(x1)

Submission status: Wrong Answer

Solution code:
n = int(input())
x = sorted(map(int, input().split()))
x1 = x[n//2-1]
x2 = x[n//2]
for i, xx in enumerate(x):
    if xx <= x1:
        print(x2)
    else:
        print(x1)

Submission status: Wrong Answer

Solution code:
n = int(input())
x = sorted(map(int, input().split()))
x1, x2 = x[n//2-1], x[n//2]
for i, xx in enumerate(x):
    if xx <= x1:
        print(x2)
    else:
        print(x1)

Submission status: Wrong Answer

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-1)/2)-1])

Submission status: Wrong Answer

Solution code:


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

    nums = sorted(X)
    dic = {}

    for x in X:
        if x not in dic:
            dic[x] = False
        else:
            dic[x] = True

    for x in X:
        if dic[x]:
            ind = nums.index(x)
            edited = nums[:ind] + nums[ind+1:]

            print(edited[len(edited)//2])
        else:
            print(nums[len(nums)//2])


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:


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

    nums = sorted(set(X))
    dic = {}

    for x in X:
        if x not in dic:
            dic[x] = False
        else:
            dic[x] = True

    for x in X:
        if dic[x]:
            ind = nums.index(x)
            edited = nums[:ind] + nums[ind+1:]

            print(edited[len(edited)//2])
        else:
            print(nums[len(nums)//2])


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:


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

    nums = list(set(X))
    dic = {}

    for x in X:
        if x not in dic:
            dic[x] = 0
        else:
            dic[x] += 1

    for x in X:
        if dic[x] < 1:
            ind = nums.index(x)
            edited = nums[:ind] + nums[ind+1:]

            print(edited[len(edited)//2])
        else:
            print(nums[len(nums)//2])



if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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 = list(set(x))

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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n = int(input())
x = input().split(" ")
b_x = [i for i in range(n)]
c = list(zip(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][0])
    else:
            print(x[n//2-1][0])

Submission status: Wrong Answer

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

    c = n // 2
    for i in range(n):
        if i < c:
            print(a[c])
        else:
            print(a[c - 1])


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n = int(input())
m = sorted(list(map(int,input().split())))
m1,m2 = m[n//2],m[n//2-1]

for i in range(n):
    if m2>=m[i]:
        print(m1)
    else:
        print(m2)

Submission status: Wrong Answer

Solution code:
n = int(input())
x = map(int, input().split())
temp = sorted(x)
idx = n // 2
y = temp[idx-1]
z = temp[idx]
for item in x:
    if item >= z:
        print(y)
    else:
        print(z)

Submission status: Wrong Answer

Solution code:
n = int(input())
x = map(int, input().split())
temp = sorted(x)
idx = n//2
y = temp[idx-1]
z = temp[idx]
for item in x:
    if item <= y:
        print(z)
    else:
        print(y)

Submission status: Wrong Answer

Solution code:
n = int(input())
x = map(int, input().split())
temp = sorted(x)
idx = n//2
y = temp[idx-1]
z = temp[idx]
for item in x:
    if item < y:
        print(y)
    else:
        print(z)

Submission status: Wrong Answer

Solution code:
def medians(nums, n):
    median_left = nums[(n + 1)//2]
    median_right = nums[(n + 1)//2 - 1]
    return median_left, median_right


if __name__ == '__main__':
    n = int(input())
    nums = list(map(int, input().split()))
    median_left, median_right = medians(sorted(nums), n)
    for i in nums:
        print(median_left) if i <= median_left else print(median_right)

Submission status: Wrong Answer

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={0}
    for j in range(N):
        if j==i:
            continue        
        M.add(X[j])
    Med=list(M)
    #print(M)
    if (len(M))%2==1:
        median = (len(M)+1)//2
    else:
        median=len(M)//2
    print(Med[median])

Submission status: Wrong Answer

Solution code:
N = int(input().strip())
X = list(map(int,input().strip().split(' ')))
sorted_X = sorted(X)
med_l=sorted_X[int(N/2-1)]
med_r=sorted_X[int(N/2)]
print(sorted_X)
for iX in X:
    if iX <= med_l:
        print(med_r)
    elif med_r <= iX:
        print(med_l)

Submission status: Wrong Answer

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

max_mid = sx[int(n/2)]
min_mid = sx[int(n/2-1)]

for i in x:
    if i <= min_mid:    # 左半分から取られてる時
        print(max_mid)
    else:               # 右半分から取られてる時
        print(min_mid)

Submission status: Wrong Answer

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

print(sx)
max_mid = sx[int(n/2)]
min_mid = sx[int(n/2-1)]

for i in x:
    if i <= min_mid:    # 左半分から取られてる時
        print(max_mid)
    else:               # 右半分から取られてる時
        print(min_mid)

Submission status: Wrong Answer

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

max_mid = sx[int(n/2)]
min_mid = sx[int(n/2)-1]

for i in x:
    if i <= min_mid:    # 左半分から取られてる時
        print(max_mid)
    else:               # 右半分から取られてる時
        print(min_mid)

Submission status: Wrong Answer

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

mid1 = sx[int(n/2)]
mid2 = sx[int(n/2)-1]

for i in x:
    if i <= mid1:
        print(mid1)
    else:
        print(mid2)

Submission status: Wrong Answer

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

mid1 = sx[int(n/2)]
mid2 = sx[int(n/2-1)]

for i in x:
    if i < mid1:
        print(mid1)
    else:
        print(mid2)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:


if __name__ == "__main__":

    n = int(input())

    number_list = list(map(int,input().split()))
    number_list.sort()
    for i in range(n):
        if i < (n/2):
            print(number_list[int(n/2)])
        else :
            print(number_list[int(n/2)-1])

Submission status: Wrong Answer

Solution code:
if __name__ == "__main__":

    n = int(input())

    number_list = list(map(int,input().split()))
    number_list.sort()
    for i in range(n):
        if i < (n/2):
            print(number_list[int(n/2)])
        else :
            print(number_list[int(n/2)-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=abs(k-a[i])
        aru=a[i]

print(enu,aru)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
y = sorted(a)
yl = y[n//2-1]
yr = y[n//2]
for i in range(n):
    print(yr if a[i] <= yr else yl)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import copy
N = int(input())
X = [int(x) for x in input().split()]
Y = copy.copy(X)
X.sort()  #ソートした

for i in range(0,N):
    if Y[i] <= X[(N // 2) -1]:
        print(X[(N // 2) -1])
    else:
        print(X[(N // 2)])

Submission status: Wrong Answer

Solution code:
from statistics import median


N = int(input())

X = input().split()
X = [ int(x) for x in X]
"""
N = 4
X = [2,4,4,3]
"""
median = median(X)
#F = copy.deepcopy(X)
"""
F = X[:]
F.sort()

median1 = int(N/2 - 1)
median2 = int(N/2) 
"""
if median.is_integer():
    median1 = median
    median2 = median
else:
    median1 = median - 0.5
    median2 = median + 0.5
    
for i in range(N):
    #print(F, median1, median2)
    
    if X[i] < median:
        ans = median2
    else:
        ans = median1
    print(int(ans))

Submission status: Wrong Answer

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

sortedx = x[:]
sortedx.sort()

for i in range(n):
    #ix = sortedx.index(x[i])
    #print(sortedx)
    #print(ix)
    if x[i] <= sortedx[n//2]:
        print(sortedx[n//2-1])
    else:
        print(sortedx[n//2-2])

Submission status: Wrong Answer

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

if n==2:
    print(b[1])
    print(b[0])
    exit()
    
bs=sorted(b,reverse=True)

bl=[]
for i in b:
    indexb=bs.index(i)
    bl.append(indexb)
    bs[indexb]=-1
bs=sorted(bl[1:n])
mid=n//2-1
bd=dict(zip(bl,b))
print(bd[mid])


for i in range(1,n):
    if bl[i-1]>=mid>=bl[i]:
        mid+=1
    elif bl[i-1]<=mid<=bl[i]:
        mid-=1
    print(bd[mid])

Submission status: Wrong Answer

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

N = int(input())
target = N//2-1
X = [0] + sorted(list(map(int, input().split())))

for i in range(1, N+1):
  l = X[1:i] + X[i+1:N+1]
  print(l[target])

Submission status: Wrong Answer

Solution code:
N = int( input())
halfN=int(N/2)
Xs = list(map(int, input().split()))
Xssorted = Xs[:]
Xssorted.sort(reverse=True)
a = Xssorted[halfN-1]
b = Xssorted[halfN]

for i,x in enumerate(Xs):    
    if x >= b:
        print(b)
    else :
        print(a)

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 - 1

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())
halfN=int(N/2)
Xs = list(map(int, input().split()))
Xssorted = Xs[:]
Xssorted.sort(reverse=True)
a = Xssorted[halfN-1]
b = Xssorted[halfN]
print(Xssorted)
for i,x in enumerate(Xs):
    if x >= b:
        print(b)
    else :
        print(a)

Submission status: Wrong Answer

Solution code:
N = int(input())
X_list = list(map(int, input().split()))
X_copy = X_list.copy()
X_copy.sort()
div = int(N / 2)

a, b = X_copy[div - 1], X_copy[div]

for i in X_list:
    if i == b:
        print(a)
    else:
        print(b)

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:
N = int( input())
halfN=int(N/2)
Xs = list(map(int, input().split()))
Xssorted = Xs[:]
Xssorted.sort(reverse=True)
a = Xssorted[halfN-1]
b = Xssorted[halfN]
print(Xssorted)
for i,x in enumerate(Xs):
    
    if x >= b:
        print(b)
    else :
        print(a)

Submission status: Wrong Answer

Solution code:
N = int(input())
a = [int(i) for i in input().split()]
s = sorted(range(len(a)), key=lambda k: a[k])
for i in range(N):
    sorted_list = s[:i] + s[i+1:]
    print(a[sorted_list[int((N-1)/2)]])

Submission status: Wrong Answer

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

x.sort()

for i in range(n):
    ix = x.index(x[i])
    #print(sortedx)
    #print(ix)
    if ix < n/2:
        print(x[n//2])
    else:
        print(x[n//2-1])

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
N = int(input())
X = tuple(map(int,input().split()))
print(X)
for i in range(len(X)):
    temp = list(X)
    temp.pop(i)
    test = int((len(temp)+1)/2)
    temp = sorted(temp)
    print(temp[test-1])

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*
n = int(raw_input())
x =[]
x = map(int, raw_input().split())
x.sort()

for i in range(n):
 b = int(n+1/2)
 print(b)

Submission status: Wrong Answer

Solution code:
N = int( input())
halfN=int(N/2)
Xs = list(map(int, input().split()))
Xssorted = Xs[:]
Xssorted.sort()
a = Xssorted[halfN-1]
b = Xssorted[halfN]
print(Xssorted)
for i,x in enumerate(Xs):
    
    if x < b:
        print(b)
    else :
        print(a)

Submission status: Wrong Answer

Solution code:
import copy

N = int(input())

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

center = N // 2 - 1

B = copy.deepcopy(X)
X.sort(reverse=True)

for i in range(N):
    a = B[i]

    if a == X[center]:
        print(X[center + 1])
    else:
        print(X[center])

Submission status: Wrong Answer

Solution code:

N=int(input())
X_list=list(map(int,input().split()))
a=int(N/2-1)
for i in range(N):
    Xcopy=list(X_list)
    Xcopy[i]=0
    Xcopy.sort(reverse=True)
    print(Xcopy)
    print(Xcopy[a])

Submission status: Wrong Answer

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

# スペース区切りの整数の入力
N = int(input())
X = list(map(int, input().split()))
md = int(N/2)
d = {}
for x in X:
    if x in d:
        d[x] += 1
    else:
        d[x] = 1

for i in range(N):
    d_cp = {}
    for j in d:
        d_cp[j] = d[j]
    d_cp[X[i]] += -1
    sum_w = 0
    cum = []
    for i, key in enumerate(d_cp):
        sum_w += d_cp[key]
        cum.append([i,key,sum_w])
    for i,key,c in cum:
        if c >= md:
            print(key)
            break

Submission status: Wrong Answer

Solution code:
n = int(input())
x = sorted(map(int, input().split()))
if n == 1:
    print(x)
else:
    x1, x2 = x[n//2-1], x[n//2]
    for i, xx in enumerate(x):
        if xx <= x1:
            print(x2)
        else:
            print(x1)

Submission status: Wrong Answer

Solution code:
import numpy as np
import sys
N = int(raw_input())
nums = map(int, raw_input().split())
nums.sort()

Submission status: Wrong Answer

Solution code:
import copy

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

X = sorted(X)
for i in range(N):
    ans1 = X[int(len(X)/2)]
    ans2 = X[int(len(X)/2)-1]
    if tmp[i] != ans1:
        print(ans1)
    else:
        print(ans2)

Submission status: Wrong Answer

Solution code:
n = int(input())
x = sorted(map(int, input().split()))
x1, x2 = x[n//2-1], x[n//2]
for i, xx in enumerate(x):
    if xx <= x1:
        print(x2)
    else:
        print(x1)

Submission status: Wrong Answer

Solution code:
n = input()
x = sorted(map(int, input().split()))
x1, x2 = x[len(x)//2-1], x[len(x)//2]
for i, xx in enumerate(x):
    if xx <= x1:
        print(x2)
    else:
        print(x1)

Submission status: Wrong Answer

Solution code:
def m():
    N = int(input())
    X = [int(x) for x in input().split()]
    XX = [x for x in X]
    XX.sort()
    first = XX[N//2]
    second = XX[N//2 -1]
    if first == second:
        for x in range(N):
            print(first)
        return 

    for x in range(N):
        if X[x] == first:
            print(second)
        else:
            print(first)


m()

Submission status: Wrong Answer

Solution code:
n = input()
x = sorted(map(int, input().split()))
x1, x2 = x[len(x)//2-1], x[len(x)//2]
for i, xx in enumerate(x):
    if xx < x1:
        print(x2)
    else:
        print(x1)

Submission status: Wrong Answer

Solution code:
d = int(input())
a = list(map(int, input().split()))
e=int(d/2)
b = []
for i in range(d):
    for j in range(d):
        b.append(a[j])
    del b[i]
    print(b[e-1])
    b.clear()

Submission status: Wrong Answer

Solution code:
def solve(N, A):
    c = int(N / 2)
    left = sorted(A)[c - 1]
    right = sorted(A)[c]
    for x in range(N):
        if A[x] <= left:
            print(right)
        if A[x] >= right:
            print(left)
            
if __name__ == "__main__":
    N = int(input())
    A = list(map(lambda x: int(x), input().split()))
    solve(N, A)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import numpy as np
N = int(raw_input())
nums = map(int, raw_input().split())

Submission status: Wrong Answer

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

y = sorted(x, reverse=True)
me1 = y[n//2-1]
me2 = y[n//2]
for i in range(n):
    if i == n//2 - 1:
        print(me2)
    elif i == n//2:
        print(me1)
    elif x[i] <= me2:
        print(me1)
    else:
        print(me2)

Submission status: Wrong Answer

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

n = max(a)
r = n

if n_ == 2:
    print(max(a), min(a))

else:
    for i in a:
        if abs(r-int(n/2)) > abs(i-int(n/2)):
            r = i

    print(n, r)

Submission status: Wrong Answer

Solution code:
import numpy as np
import sys
N = int(raw_input())
nums = map(int, raw_input().split())
for i in range(N):
    nums_tmp = nums[0:i] + nums[i+1:N]
    nums_tmp = np.array(nums_tmp)
    #print(int(np.median(nums_tmp)))

Submission status: Wrong Answer

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

bs=sorted(b[1:n])
mid=n//2-1
print(bs[mid])
if n==2:
    print(b[0])
    exit()
for i in range(1,n):

    if b[i-1]<bs[mid]<=b[i]:
        mid-=1
    elif b[i-1]>bs[mid]>=b[i]:
        mid+=1
    print(bs[mid])

Submission status: Wrong Answer

Solution code:
def m():
    N = int(input())
    X = [int(x) for x in input().split()]
    XX = [x for x in X]
    XX.sort()
    first = XX[N//2]
    second = XX[N//2 -1]
    for x in range(N):
        if X[x] == first:
            print(second)
        else:
            print(first)


m()

Submission status: Wrong Answer

Solution code:
import numpy as np

N = int(input())
X_list = list(map(int, input().split()))
def get_median(a_list, i):
    b_list = a_list[:]
    del b_list[i]
    data = np.array(b_list)
    print(np.median(data))
for j in range(N):
    get_median(X_list, j)

Submission status: Wrong Answer

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

# AtCoder Beginner Contest
# Problem C


# See:
# https://qiita.com/suecharo/items/30f5d817da4c948c3be6
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


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

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

Submission status: Wrong Answer

Solution code:
import numpy as np

N = int(input())
X_list = list(map(int, input().split()))
def get_median(a_list, i):
    b_list = a_list[:]
    del b_list[i]
    print(np.median(b_list))
for j in range(N):
    get_median(X_list, j)

Submission status: Wrong Answer

Solution code:
import numpy as np

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

sorted_A = np.sort(A)
sort_list = np.argsort(A)

for i in range(len(A)):
	sorted_A_i = np.delete(sorted_A, sort_list[i])
	print(sorted_A_i[int(len(A)/2 - 1)])

Submission status: Wrong Answer

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

a = len(x)
b = sorted(x)
fa = b[int((a/2)-1)]
se = b[int(a/2)]


for i in range(n):
    if x[i] <= a/2:
        print(fa)
    else:
        print(se)

Submission status: Wrong Answer

Solution code:
def solve(N, A):
    c = int(N / 2)
    left = A[c - 1]
    right = A[c]
    for x in range(c - 1):
        print(left)
    print(right)
    print(left)
    for x in range(c + 1, N):
        print(right)
            
if __name__ == "__main__":
    N = int(input())
    A = list(map(lambda x: int(x), input().split()))
    solve(N, A)

Submission status: Wrong Answer

Solution code:
N = int(input())
# N, A, B = map(int, input().split())
l = list(map(int, input().split()))
print(l)

for i in range(N):
    ll = l[:i] + l[i+1:]
    ll.sort()
    print(ll[N // 2 - 1])

Submission status: Wrong Answer

Solution code:
import bisect
n = int(input())
x = list(map(int,input().split()))
c = int(n/2)-1
y = list(x)
y.sort()
for i in x:
    z=list(y)
    del z[bisect.bisect(x,i,hi=n-1)]
    print(z[c])

Submission status: Wrong Answer

Solution code:
import copy
N=int(input())
X_list=list(map(int,input().split()))
a=int(N/2-1)
for i in range(N):
    Xcopy=copy.deepcopy(X_list)
    Xcopy[i]=0
    Xcopy.sort(reverse=True)
    print(Xcopy)
    print(Xcopy[a])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import copy

N = int(input())

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

center = N // 2

B = copy.deepcopy(X)
X.sort(reverse=True)

for i in range(N):
    a = B[i]

    if a == X[center]:
        print(X[center - 1])
    else:
        print(X[center])

Submission status: Wrong Answer

Solution code:
def mid(n):
    return int((n + 1) / 2)

N = int(input())
X = list(map(int, input().split()))
save = X[:]
for i in range(N):
    X = save[:]
    del X[i]
    X.sort()
    print(X[mid(N - 1) - 1])
    print(X)

Submission status: Wrong Answer

Solution code:

N=int(input())
X=list(map(int,input().split()))
Y=[X[i] for i in range(N)]
Y.sort()

a=Y[int((N-1)/2)]
b=Y[int((N+1)/2)]

for i in range(N):
    if X[i]<a:
        print(b)
    elif X[i]>b:
        print(a)
    else:
        if X[i]==a:
            print(b)
        if X[i]==b:
            print(a)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N=int(input())
List=list(map(int,input().split()))
N=len(List)
lastindex=N//2
AList=List[:]
List.sort()
print(N)
for index in range(N):
    BList=List[:]
    #BList.remove(AList[index])
    print(BList[N//2-1])

Submission status: Wrong Answer

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

a=Y[int((N-1)/2)]
b=Y[int((N+1)/2)]

for i in range(N):
    if X[i]<a:
        print(b)
    elif X[i]>b:
        print(a)
    else:
        if a==b:
            print(a)
        elif X[i]==a:
            print(b)
        else:
            print(a)

Submission status: Wrong Answer

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

import copy

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

X.sort()
X.reverse()
for i in range(0,N):
    if X[int(N/2)-1]==Y[i]:
        print(X[int(N/2)])
    else:
        print(X[int((N/2)-1)])

Submission status: Wrong Answer

Solution code:
N = int(input())
X = list(map(int,input().split()))
l = ""
for i,j in enumerate(X):
    k=X[N-1-i]
    X.pop(N-1-i)
    l+=str(sorted(X)[N//2-1])
    X.append(k)

for i in reversed(l):
    print(i)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def abc094C():
    n = int(input())
    x = input().split()
    x = list(map(int, x))
    y = x.copy()
    y.sort()
    print(y)
    nums = y[int(n / 2 - 1): int(n / 2 + 1)]
    for i in range(n):
        y = x.copy()
        tf = nums[0] >= y[i]
        del y[i]
        y.sort()
        print(nums[tf])


abc094C()

Submission status: Wrong Answer

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

tmp = n//2

tmp_array = sort_array[tmp-1:tmp+1]

for i in range(n):
    if len(array) == 2:
        print(tmp_array[i-1])
    else:
        if i == tmp or i == tmp-1:
            print(tmp_array[0])
        else:
            print(tmp_array[1])

Submission status: Wrong Answer

Solution code:
import math
n = int(input())
lis = list(map(int,input().split()))
li = sorted(lis)
ans2 = li[math.ceil((n-1)/2)]
cou2 = lis.count(ans2)
ans1 = li[math.floor((n-1)/2)]
cou1 = lis.count(ans1)
for i in range(n):
	if lis[i] < ans1:
		print(ans2)
	elif lis[i] > ans2:
		print(ans1)
	elif lis[i] == ans1:
		if cou1 > 1:
			print(ans1)
		else:
			print(ans2)
	else:
		if cou2 > 1:
			print(ans2)
		else:
			print(ans1)

Submission status: Wrong Answer

Solution code:
import copy
n = int(input())
x = list(map(int,input().split()))
y = list(x)
y.sort()
c=int(n/2)-1
d={}
for i in range(n):
    d[x.index(y[i])]=y[i]
    x[x.index(y[i])]= -1
for i in range(n):
    dt = copy.deepcopy(d)
    del dt[i]
    l = list(dt.values())
    print(l[c])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import copy
n = int(input())
x = list(map(int,input().split()))
y = list(x)
y.sort()
c=int(n/2)-1
d={}
for i in range(n):
    d[x.index(y[i])]=y[i]
    x[x.index(y[i])]= -1
for i in range(n):
    dt = copy.deepcopy(d)
    del dt[i]
    l = list(dt.values())
    print(l)
    print(c)
    print(l[c])

Submission status: Wrong Answer

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

mid_left = sortx[(n//2)-1]
mid_right = sortx[(n//2)]

for i in range(n):
    if sortx[i] <= mid_left:
        print(mid_right)
    else:
        print(mid_left)

Submission status: Wrong Answer

Solution code:
n=int(input())
x=list(map(int,input().split()))
N=int(n/2)
for i in range(n):
    y=[]
    for j in range(n):
        if j!=i:
            y.append(x[j])
    print(y)
    y.sort()
    print(y[N-1])

Submission status: Wrong Answer

Solution code:
import numpy as np

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

M = np.median(X)

Y = sorted(X)
a = Y[int(len(Y)/2 - 1)]
b = Y[int(len(Y)/2)]

for x in X:
    if x <= a:
        print(a)
    else:
        print(b)

Submission status: Wrong Answer

Solution code:
n = int(input())
x = list(map(int,input().split()))
y = list(x)
y.sort()
c=int(n/2)-1
d={}
for i in range(n):
    d[x.index(y[i])]=y[i]
    x[x.index(y[i])]= -1
for i in range(n): 
    dt = dict(d)
    del dt[i]
    l = list(dt.values())
    print(l[c])

Submission status: Wrong Answer

Solution code:
import numpy as np

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

M = np.median(X)

Y = sorted(X)
a = Y[int(len(Y)/2 - 1)]
b = Y[int(len(Y)/2)]

for x in X:
    if x < M:
        print(a)
    else:
        print(b)