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:
import copy
N = int(input())
X = list(map(int, input().split()))
XX = sorted(X)
for i in range(N):
    delX = copy.copy(XX)
    delX.remove(X[i])
    # print(delX)
    print(delX[N // 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):
    delX = copy.copy(X)
    delX.remove(X[i])
    delX.sort()
    print(delX[N // 2 - 1])
    # print(delX)
# print(N, X)

Submission status: Time Limit Exceeded

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

for n in range(N):
  Y = X[:]
  Y.pop(n)
  print(statistics.median(Y))

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
x = list(map(int, input().split()))
x1 = []
for i, xi in enumerate(x):
    x1.append([i, xi])

x_sort = sorted(x1, key=lambda x: x[1])
t = int(n / 2)
lxt = []
for i in range(n):
    if i < t:
        lxt.append(x_sort[i][0])
    else:
        break

for i in range(n):
    if i in lxt:
        print(x_sort[t][1])
    else:
        print(x_sort[t - 1][1])

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

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

for i in range(n):
    B = A[:i] + A[i+1:]
    B = sorted(B)
    print(B[(n)//2-1])

Submission status: Time Limit Exceeded

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

h = (n//2)-1
for i in range(n):
  x = s[:i]+s[i+1:]
  sx = sorted(x)
  print(sx[h])

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
X = [int(i) for i in input().split()]
for i in range(N):
    start = i + 1
    x = sorted(X[:i] + X[start:])
    l = len(x)
    b = (l + 1) // 2
    print(x[b - 1])

Submission status: Time Limit Exceeded

Solution code:
import math
import statistics
import copy

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

for i in range(N):
  a = copy.copy(li)
  a.pop(i)
  print(statistics.median(a))

Submission status: Time Limit Exceeded

Solution code:
import math
import statistics

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

for i in range(N):
  a = []
  for index, k in enumerate(li):
    if i == index:
      continue
      
    a.append(k)
    
  print(statistics.median(a))

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

    for i in range(N):
        print(sorted([X[x] for x in range(N) if x != i])[(N-1)//2])
if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Median_i=N//2-1

for i in range(N):
    X_=X[:]
    del X_[i]
    X_.sort()
    print(X_[Median_i])

Submission status: Time Limit Exceeded

Solution code:
import statistics
from collections import deque

d = deque()

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

#print(d)

for i in range(a):
  b = d.pop(0)
  print(statistics.median(d))
  d.append(b)
#  print(d)

Submission status: Time Limit Exceeded

Solution code:
import statistics

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

for i in range(a):
  b = l.pop(0)
  print(statistics.median(l))
  l.append(b)

Submission status: Time Limit Exceeded

Solution code:
import copy
n = int(input())
x = list(map(int,input().split()))
for i in range(n):
    temp1 = x.pop(i)
    temp2 = copy.copy(x)
    temp2.sort()
    print(temp2[len(temp2)//2])
    x.insert(i,temp1)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
x = tuple(map(int,input().split()))
x_sort = sorted(x,reverse=True)
for i in range(n):
    print(x_sort[n//2] if x_sort.index(x[i]) < n//2 else x_sort[n//2-1])

Submission status: Time Limit Exceeded

Solution code:
import math
import calendar
import fractions
import itertools

n = int(input())

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

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

Submission status: Time Limit Exceeded

Solution code:
import copy
 
n = int(input())
x = list(map(int,input().split()))
 
 
for i in range(n):
  xx = copy.deepcopy(x)
  xx.pop(i)
  xx.sort()
  print(xx[(len(xx) + 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):
  xx = copy.deepcopy(x)
  xx.pop(i)
  xx.sort()
  print(xx[(len(xx) + 1) // 2 - 1])

Submission status: Time Limit Exceeded

Solution code:
import copy 
def pin(type=int):
    return map(type,input().split())

N,= pin()
lis = list(pin())

for i in range(N):
    lisX = copy.copy(lis) 
    lisX.pop(i)
    #print (lisX,[(N-1)//2])
    lisX.sort()
    print (lisX[(N-1)//2])
#print(lis,lisX)

Submission status: Time Limit Exceeded

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

C = int(N / 2)

for i in range(N):
  AS = S[:i] + S[i+1:]
  SortedA = sorted(AS, reverse=True)
  print(SortedA[C-1])

Submission status: Time Limit Exceeded

Solution code:
def median(list):
  list.sort()
  i = (len(list)-1)//2
  return list[i]
n=int(input())
x=list(map(int,input().split()))
for i in range(n):
  y=x.copy()
  del y[i]
  print(median(y))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import sys
input = sys.stdin.readline
n = int(input())
x = list(map(int, input().split()))
lists = []
ind = ((n-1) + 1) // 2
for i in range(n):
    if i == 0:
        ans = x[i + 1:]
        ans.sort()
        lists.append(ans[ind-1])
    else:
        ans = x[0:i] + x[i + 1:]
        ans.sort()
        lists.append(ans[ind - 1])
[print(x) for x in lists]

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
x = list(map(int, input().split()))
lists = []
ind = ((n-1) + 1) // 2
for i in range(n):
    if i == 0:
        ans = x[i + 1:]
        ans.sort()
        lists.append(ans[ind-1])
    else:
        ans = x[0:i] + x[i + 1:]
        ans.sort()
        lists.append(ans[ind - 1])
tuple_lists = tuple(lists)
[print(x) for x in tuple_lists]

Submission status: Time Limit Exceeded

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

for i in range(n):
    x_ = xlst.copy()
    x_.pop(i)
    x_.sort(reverse=True)
    print(x_[n//2-1])

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:
N=int(input())
X=list(map(int,input().split()))
tmp=[]
for i in range(N):
    tmp=sorted(X[0:i]+X[i+1:])
    print(tmp[len(tmp)//2])

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
x = [int(i) for i in input().split()]
xs = sorted(x)
for i in range(n):
  xi = xs.copy()
  xi.remove(x[i])
  print(xi[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):
  print(sorted(x[:i] + x[i + 1:])[n // 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):
    y=copy.copy(x)
    del y[i]
    y.sort()
    print(y[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=[]
    for j in range(n):
        if j!=i:
            y.append(x[j])
    y.sort()
    print(y[n//2-1])

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = list(map(int, input().split()))
for i in range(n):
    s = a[i]
    del a[i]
    b = sorted(a)
    print(b[int(n/2-1)])
    a.insert(i, s)

Submission status: Time Limit Exceeded

Solution code:
def main():
    import sys
    n=int(sys.stdin.readline())
    m=(n-1)//2+2
    x=tuple(map(int,input().split()))
    x = (0,) + x + (0,)
    for i in range(n):
        print(sorted(x[:i+1]+x[i+2:])[m])
if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
x=list(map(int,input().split()))
for i in range(n):
    k=x.pop(0)
    y=x[:] #deepcopyと同じ.
    print(sorted(y)[(n-1)//2])
    x.append(k)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import sys
readline = sys.stdin.readline
N = int(readline())
X = [int(x) for x in readline().split()]
sX = sorted(X)
h = {}
for i in range(len(sX)):
    h[sX[i]] = i
for i in range(N):
    p = h[X[i]]
    lr = sX[:p] + sX[p+1:]
    print(lr[len(lr) // 2])

Submission status: Time Limit Exceeded

Solution code:
from bisect import bisect_left
import sys
readline = sys.stdin.readline
N = int(readline())
X = [int(x) for x in readline().split()]
sX = sorted(X)
for i in range(N):
    p = bisect_left(sX, X[i])
    lr = sX[:p] + sX[p+1:]
    print(lr[len(lr) // 2])

Submission status: Time Limit Exceeded

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

sX = sorted(X)

for i in range(N):
    p = bisect_left(sX, X[i])
    lr = sX[:p] + sX[p+1:]
    print(lr[len(lr) // 2])

Submission status: Time Limit Exceeded

Solution code:
import sys
input = sys.stdin.readline
import numpy as np
N = int(input())
X = [int(x) for x in input().split()]
for i in range(N):
    temp = X[:i] + X[i+1:]
    print(int(np.median(temp)))

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
li = list(map(int,input().split()))
lia = li[:]
for i in range(N) :
    del lia[i]
    lia.sort()
    ave = int((N-2)/2)
    a = lia[ave]
    lia = li[:]
    print(a)

Submission status: Time Limit Exceeded

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


def median(a: list):
    l = len(a)
    i = l/2 if (l % 2 == 0) else (l+1)/2
    return sorted(a)[int(i)-1]


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

Submission status: Time Limit Exceeded

Solution code:
import sys
import copy
sys.setrecursionlimit(10**6)
if sys.platform in (['ios','darwin','win32']):
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

N = INT()
A = MAP()

B = copy.deepcopy(A)
B.sort()

med = N//2

for i,a in enumerate(A):
	if B.index(a)>=med:
		print(B[med-1])
	else:
		print(B[med])

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
a=list(map(int,input().split()))
for i in range(n):
  b=a[:]
  b.pop(i)
  b.sort()
  print(b[(len(b)+1)//2-1])

Submission status: Time Limit Exceeded

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

for i in range(N):
	print((Y[:Y.index(X[i])]+Y[Y.index(X[i])+1:])[N//2-1])

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
X=list(map(int,input().split()))
print('\n'.join(map(str,[sorted(X[:i]+X[i+1:])[N//2-1] for i in range(N)])))

Submission status: Time Limit Exceeded

Solution code:
import sys
import statistics
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

N = int(input())
X = list(map(int, input().split()))
mid = N // 2 - 1

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

Submission status: Time Limit Exceeded

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

N = int(input())
X = list(map(int, input().split()))
mid = N // 2 - 1

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

Submission status: Time Limit Exceeded

Solution code:
import statistics

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

for i in range(len(Xs)):
    Xs_i=Xs[:i]+Xs[i+1:]
    med=statistics.median(Xs_i)
    print(med)

Submission status: Time Limit Exceeded

Solution code:
import statistics
N = int(input())
Xlist = list(map(int, input().split()))
for i in range(N):
    a = Xlist[0:i] + Xlist[i + 1:]
    print(statistics.median(a))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import copy
import statistics
N = int(input())
X = list(map(int, input().split()))
for i in range(N):
    med = copy.deepcopy(X)
    med.pop(i)
    print(statistics.median(med))

Submission status: Time Limit Exceeded

Solution code:
from statistics import median
N = int(input())
X = [int(i) for i in input().split()]
for n in range(N):
    temp = X[:n] + X[n+1:]
    print(median(temp))

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
*l, = map(int, input().split())

for i in range(n):
    _l = l[:]
    _l.pop(i)
    _l.sort()
    print(_l[(n-1)//2])

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
x = list(int(i) for i in input().split())
for i in range(N):
    a = x.pop(i)
    print(sorted(x)[int(N/2-1)])
    x.insert(i,a)

Submission status: Time Limit Exceeded

Solution code:
from bisect import bisect_left
N = int(input())
X = list(map(int,input().split()))
subX = X[1:]
subX.sort()
for i in range(N-1):
    print(subX[N//2-1])
    k = bisect_left(subX,X[i])
    subX.insert(k,X[i])
    k = bisect_left(subX,X[i+1])
    subX.pop(k)
print(subX[N//2-1])

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import bisect

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

m = (n-1) // 2
 
x_sorted = sorted(x)

ans = []

for i in range(n):
    ind = bisect.bisect_left(x_sorted, x[i])
    ans.append(x_sorted[0:ind] + x_sorted[ind+1:])

for i in range(n):
    print(ans[i][m])

Submission status: Time Limit Exceeded

Solution code:
import bisect

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

m = (n-1) // 2
 
x_sorted = sorted(x)

for i in range(n):
    ind = bisect.bisect_left(x_sorted, x[i])
    print((x_sorted[0:ind] + x_sorted[ind+1:])[m])

Submission status: Time Limit Exceeded

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

m = (n-1) // 2
 
x_sorted = sorted(x)

for i in range(n):
    ind = x_sorted.index(x[i])
    print((x_sorted[0:ind] + x_sorted[ind+1:])[m])

Submission status: Time Limit Exceeded

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

for i in range(n):
    print(sorted(x[0:i] + x[i+1:])[(n-1)//2])

Submission status: Time Limit Exceeded

Solution code:
import statistics
import copy

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

for i in range(N):
    buf = copy.copy(X)
    buf.pop(i)
    print(statistics.median(buf))

Submission status: Time Limit Exceeded

Solution code:
import math
import copy
#import sys
#import bisect
#input = sys.stdin.readline
def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)
def lcm(a, b):
    return((a*b)//gcd(a,b))

def main():
    #x,y = map(int,input().split())	x=1,y=2
    #a = input().split()	a=['1','2','3',...,'n']
    #a = list(map(int,input().split()))	a=[1,2,3,4,5,...,n]
    #li = input().split('T')	FFFTFTTFF => li=['FFF', 'F', '', 'FF']
    n=int(input())
    a = list(map(int,input().split()))
    b=copy.copy(a)
    for i in range(n):
        x=b[i]
        a.sort()
        if x<=a[(n//2)-1]:
            print(a[(n//2)])
        else:
            print(a[(n//2)-1])

main()

Submission status: Time Limit Exceeded

Solution code:
#import math
#import sys
#import bisect
#input = sys.stdin.readline
def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)
def lcm(a, b):
    return((a*b)//gcd(a,b))

def main():
    #x,y = map(int,input().split())	x=1,y=2
    #a = input().split()	a=['1','2','3',...,'n']
    #a = list(map(int,input().split()))	a=[1,2,3,4,5,...,n]
    #li = input().split('T')	FFFTFTTFF => li=['FFF', 'F', '', 'FF']
    n=int(input())
    a = list(map(int,input().split()))
    for i in range(n):
        x=[]
        for j in range(n):
            if i!=j:
                x.append(a[j])
        x.sort()
        y=len(x)
        if len(x)%2==1:
            print(x[((y+1)//2)-1])
        else:
            print((x[y//2]+x[(y//2)-1])/2)
main()

Submission status: Time Limit Exceeded

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

def getMedian(a):
    #a = sorted(set(a))
    a = sorted(a)
    return a[(len(a)+1)//2-1]
    # if len(a) % 2 == 0:
    #     return a[(len(a))//2-1]
    # else:
    #     return a[(len(a)+1)//2-1]

for i in range(n):
    temp = list(x)
    del temp[i]
#    print(temp)
    print(getMedian(temp))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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


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

Submission status: Time Limit Exceeded

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

for i in range(n):
  xx = x[:i] + x[i+1:]
  print(statistics.median(xx))

Submission status: Time Limit Exceeded

Solution code:
n = int(input())

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

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
ary = list(map(int,input().split()))
a = sorted(ary)
c = (len(ary)+1)//2-1
for i in range(n):
    b = a.copy()
    b.remove(ary[i])
    print(b[c])

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
ary = list(map(int,input().split()))
b = (len(ary)+1)//2-1
for i in range(n):
    a = ary.copy()
    del a[i]
    a.sort()
    print(a[b])

Submission status: Time Limit Exceeded

Solution code:
#094c
import copy
N = int(input()) #N<200000=2 * 10**5
X_list = [int(e) for e in input().split()]
#print(X_list)

for i in range(N):
    copy_X_list = copy.copy(X_list)
    copy_X_list.pop(i)
    copy_X_list.sort(reverse=False)
    #print(copy_X_list)
    print(copy_X_list[int(len(X_list)/2) -1])

Submission status: Time Limit Exceeded

Solution code:
# 入力
n = int(input())
org_nums = list(map(int, input().split()))
# ソートは一回だけして、取り去る順番を明確にしてから１つずつ取り去り計算を行いたい
sorted_nums = sorted(org_nums) # 入力数列のソート
sorted_index = sorted(range(len(org_nums)), key=lambda k: org_nums[k]) #ソートされたリストから取り去る順番がわかる
extract_index = sorted(range(len(sorted_index)), key=lambda k: sorted_index[k]) #ソートされたリストから取り出すインデックスを取り出す順に並べる
#print(sorted_index)
#print(extract_index)
for i in extract_index:
    tmp = sorted_nums.copy()
    tmp.pop(i)
    print(tmp[(n-1)//2])

Submission status: Time Limit Exceeded

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

m = int(n/2)-1
x_tmp = sorted(x)
# print(x_tmp)

for i in range(n):
    if x_tmp.index(x[i]) > m:
        print(x_tmp[m])
    else:
        print(x_tmp[m+1])

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
x = [int(i) for i in input().split()]
x = sorted([[x[i], i] for i in range(n)])
#print(x)
ans = [0]*n
#print(ans)
for i in range(n):
  x_ = x[:i]+x[i+1:]
#  print(x_)
  ans[x[i][1]] = x_[n//2-1][0]
for i in range(n):
  print(ans[i])

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
X=list(map(int,input().split()))
X_s=sorted(X)
for i,x in enumerate(X):
    t=X_s.index(x)
    X_s.pop(t)
    print(X_s[(N-1)//2])
    X_s.insert(t,x)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = list(map(int,input().split()))
b = list(a)
c = int(n/2)
for j in range(1,c):
    b.remove(max(b))
    b.remove(min(b))
ML = min(b)
MR = max(b)
for i in range(0,n):
    if a[i] >= MR:
        print(ML)
    else:
        print(MR)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
a = list(map(int,input().split()))
b = list(a)
c = int(n/2)
for j in range(1,c):
    M = max(b)
    m= min(b)
    b.remove(M)
    b.remove(m)
ML = min(b)
MR = max(b)
for i in range(0,n):
    if a[i] >= MR:
        print(ML)
    else:
        print(MR)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
x = list(map(int, input().split()))
import copy
l1 = copy.copy(x)
l1.sort()
for i in range(n):
    place = l1.index(x[i])
    l1.remove(x[i])
    print(l1[int((n / 2) - 1)])
    l1.insert(place, x[i])

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
x = list(map(int,input().split()))
y = []
z = []
for i in range(n):
  y.append([x[i],i])
y.sort()
for i in range(int(n/2)):
  z.append(y[i][1])
m = y[int(n/2)-1][0]
M = y[int(n/2)][0]
for i in range(n):
  if i in z:
    print(M)
  else:
    print(m)

Submission status: Time Limit Exceeded

Solution code:
def except_arr(arr, i):
    pre = arr[0:i]
    post = arr[i+1:]
    return pre+post

def mean(arr):
    l = len(arr)-1
    m = round(l/2)
    if m > l:
        m -= 1
    arr.sort()
    return arr[m]

def cc094():
    n = int(input())
    xn = list(map(int, input().split()))

    for i in range(0,n):
        print(mean(except_arr(xn, i)))

cc094()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

x_1 = x_sorted[n // 2 - 1]
x_2 = x_sorted[n // 2]

for i in x:
    if x_sorted.index(i) < n // 2:
        print(x_2)
    else:
        print(x_1)

Submission status: Time Limit Exceeded

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

for i in range(N):
    tmp = x.pop(i)
    tmplst = sorted(x)
    print(tmplst[(N - 1) // 2])
    x.insert(i, tmp)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import copy
N=int(input())
X=list(map(int,input().split()))
l=copy.copy(X)
for i in range(N):
    X.remove(l[i])
    X.sort(reverse=True)
    print(X[int((N-2)/2)])
    X.insert(i,l[i])

Submission status: Time Limit Exceeded

Solution code:
# ABC094 C - Many Medians
n = int(input())
x = list(map(int,input().split()))

for i in range(n):
    y = x[:]
    y[i] = 0
    y.sort()
    print(y[int((n/2))])

Submission status: Time Limit Exceeded

Solution code:
# ABC094 C - Many Medians
n = int(input())
x = list(map(int,input().split()))

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

for i in range(N):
    x = sorted(X)
    x.remove(X[i])
    print(x[-N // 2])

Submission status: Time Limit Exceeded

Solution code:
import statistics
N = int(input())
X = list(map(int,input().split()))
for i in range(1,N+1):
    tmp = X[0:i-1]+X[i:]
    print(statistics.median(tmp))

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

def c(arr):
  arr.sort(reverse=True)
  l=len(arr)
  num=(l+1)//2 - 1
  return arr[num]

for i in range(n):
  a=x[:i]+x[i+1:]
  print(c(a))

Submission status: Time Limit Exceeded

Solution code:
import statistics
import math
N=int(input())
X=list(map(int,input().split()))
for i in range(N):
  l=X[:i]+X[i+1:]
  med=statistics.median(l)
  print(med)

Submission status: Time Limit Exceeded

Solution code:
import statistics
import math
import copy

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

for i in range(n):
  tmp = copy.copy(x)
  tmp.pop(i)
  print(statistics.median(tmp))

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
x=list(map(int, input().split()))
ll=(len(x)-1)//2

for i in range(n):
    xx=x.copy()
    del xx[i]
    xx=sorted(xx,reverse=True)
    print(xx[ll])

Submission status: Time Limit Exceeded

Solution code:
from copy import copy

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

for xi in X:
    Y = copy(X)
    Y.remove(xi)
    print(sorted(Y)[N // 2 - 1])

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
x = list(map(int, input().split()))
ans = []
for i in range(n):
    xx = x.copy()
    delete = xx.pop(i)
    xxx = sorted(xx)
    print(xxx[(n-1)//2])

Submission status: Time Limit Exceeded

Solution code:
# https://atcoder.jp/contests/abc094/tasks/arc095_a
# C - Many Medians
import copy

n = int(input().split()[0])
x_list = list(map(int, input().split()))
sorted_x_list = sorted(x_list)
mean_index = int((n + 1)/ 2) - 1
mean_list = []

a = str(sorted_x_list[mean_index])
b = str(sorted_x_list[mean_index + 1])
mean_list = [b if sorted_x_list.index(x) < n / 2 else a for x in x_list]

ans = '\n'.join(mean_list)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
# https://atcoder.jp/contests/abc094/tasks/arc095_a
# C - Many Medians
import copy

n = int(input().split()[0])
x_list = list(map(int, input().split()))
sorted_x_list = sorted(x_list)
mean_index = int((n + 1)/ 2) - 1
mean_list = []

index_list = [sorted_x_list.index(x) for x in x_list]

for index in index_list:
    if index < n - 1:
        w_list = sorted_x_list[:index] + sorted_x_list[index+1:]
    else:
        w_list = sorted_x_list[:index]

    mean_value = w_list[mean_index]
    mean_list.append(str(mean_value))

ans = '\n'.join(mean_list)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
# https://atcoder.jp/contests/abc094/tasks/arc095_a
# C - Many Medians
import copy

n = int(input().split()[0])
x_list = list(map(int, input().split()))
sorted_x_list = sorted(x_list)
mean_index = int((n + 1)/ 2) - 1
mean_list = []

for i, x in enumerate(x_list):
    w_list = copy.copy(sorted_x_list)
    w_list.remove(x)
    mean_value = w_list[mean_index]
    mean_list.append(str(mean_value))

ans = '\n'.join(mean_list)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
# https://atcoder.jp/contests/abc094/tasks/arc095_a
# C - Many Medians

n = int(input().split()[0])
x_list = list(map(int, input().split()))
sorted_x_list = sorted(x_list)
mean_index = int((n + 1)/ 2) - 1
mean_list = []

for i, x in enumerate(x_list):
    if i < n - 1:
        w_list = sorted(x_list[:i] + x_list[i+1:])
    else:
        w_list = sorted(x_list[:i] + x_list[i+1:])

    mean_value = w_list[mean_index]
    mean_list.append(str(mean_value))

ans = '\n'.join(mean_list)
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n=int(input())
x=[(int(j),i) for i,j in enumerate(input().split())]
l=int((n-1)/2)

sortedList=sorted(x)
ans=[-1]*n

for i in range(n):
    xx=sortedList[:i]+sortedList[i+1:]
    pos=sortedList[i][1]
    val=xx[l][0]
    ans[pos]=str(val)

print("\n".join(ans))

Submission status: Time Limit Exceeded

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