Problem:


Score : 300 points

Problem Statement

Takahashi made N problems for competitive programming.
The problems are numbered 1 to N, and the difficulty of Problem i is represented as an integer d_i (the higher, the harder).

He is dividing the problems into two categories by choosing an integer K, as follows:

A problem with difficulty K or higher will be for ARCs.

A problem with difficulty lower than K will be for ABCs.

How many choices of the integer K make the number of problems for ARCs and the number of problems for ABCs the same?

Problem Statement

2 \leq N \leq 10^5

N is an even number.

1 \leq d_i \leq 10^5

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N
d_1 d_2 ... d_N

Output

Print the number of choices of the integer K that make the number of problems for ARCs and the number of problems for ABCs the same.

Sample Input 1

6
9 1 4 4 6 7

Sample Output 1

2

If we choose K=5 or 6, Problem 1, 5, and 6 will be for ARCs, Problem 2, 3, and 4 will be for ABCs, and the objective is achieved.
Thus, the answer is 2.

Sample Input 2

8
9 1 14 5 5 4 4 14

Sample Output 2

0

There may be no choice of the integer K that make the number of problems for ARCs and the number of problems for ABCs the same.

Sample Input 3

14
99592 10342 29105 78532 83018 11639 92015 77204 30914 21912 34519 80835 100000 1

Sample Output 3

42685



Sample input:
6
9 1 4 4 6 7


Sample output:
2

Submission status: Accepted

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

A.sort()
ans=A[N//2]-A[N//2-1]
print(ans)

Submission status: Accepted

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

x2=sorted(x)

n1=int(n/2-1)
n2=int(n/2)

if x2[n1]==x2[n2]:
	cnt=0
else:
	cnt=x2[n2]-x2[n1]

print(cnt)

Submission status: Accepted

Solution code:
N = int(input())
d = list(map(int,input().split()))
d.sort()
l = d[0:int(N/2)]
r = d[int(N/2):N]
if l[len(l)-1] == r[0]:
    print(0)
else:
    print(r[0]-l[len(l)-1])

Submission status: Accepted

Solution code:
n=int(input())
n=n/2
n=int(n)
d=[]
d=map(int,input().split())
dsort=sorted(d)
print(dsort[n]-dsort[n-1])

Submission status: Accepted

Solution code:
a = int(input())
b = list(map(int,input().split()))
b.sort()
c = b[int(a/2)] - b[int(a/2)-1]
if c > 0:
    print(c)
else:
    print(0)

Submission status: Accepted

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

d.sort()

print(d[int(N/2)] - d[int(N/2 - 1)])

Submission status: Accepted

Solution code:
N=int(input())
d=list(map(int,input().split()))
d.sort(reverse = True)
print(d[int(N/2)-1]-d[int(N/2)])

Submission status: Accepted

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

# main
N = int(input())
array_d = [int(i) for i in input().split(' ')]

difficulty = sorted(array_d)

print(difficulty[int(N/2)] - difficulty[int(N/2) - 1])

Submission status: Accepted

Solution code:
N = int(input())

d = [int(_) for _ in input().split()]

d_sort = sorted(d)

print(d_sort[N//2]-d_sort[N//2-1])

Submission status: Accepted

Solution code:
n = int(input())
d = list(map(int, input().split()))
d.sort()
half = int(n/2)
if d[half-1] == d[half]:
    print(0)
else:
    w = d[half] - d[half-1]
    print(w)

Submission status: Accepted

Solution code:
import statistics


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

    med_low = statistics.median_low(d_list)
    med_high = statistics.median_high(d_list)

    if med_high == med_low:
        answer = 0
    else:
        answer = med_high - med_low

    print(answer)

Submission status: Accepted

Solution code:
import numpy as np

N = int(input())
difficulty = np.sort(np.array([int(num) for num in input().split(" ")]))

num_K = difficulty[N/2] - difficulty[((N/2)-1)]
print(num_K)

Submission status: Accepted

Solution code:
n = int(input())
d = list(map(int,input().split()))
m = n//2
d.sort()
if d[m-1] == d[m]:
  print(0)
else:
  print(d[m] - d[m-1])

Submission status: Accepted

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

if n%2==1:
    print("0")
else:
    m=n//2
    s=sorted(d)
    ans=s[m]-s[m-1]
    print(ans)

Submission status: Accepted

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

dx=sorted(d)

if dx[int(n/2)] != dx[int(n/2-1)]:
    print(dx[int(n/2)]-dx[int(n/2-1)])
else:
    print("0")

Submission status: Accepted

Solution code:
n = int(input())
d = list(map(int,input().split()))
sd = sorted(d)
print(sd[n//2] - sd[n//2-1])

Submission status: Accepted

Solution code:
import bisect

N = int(input())
d = [0]*N
d = list(map(int, input().split()))
ans = int(0)

d.sort()

for i in range(100001):
    if(bisect.bisect_left(d, i)==N/2):
        ans +=1


print(ans)

Submission status: Accepted

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

K = 0

d.sort()

sum = d[n//2] - d[n//2-1]

print (sum)

Submission status: Accepted

Solution code:
n=int(input())
list=[int(x) for x in input().split()]
list.sort()
ans = list[int(n/2)]-list[int(n/2)-1]
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
d = list(map(int, input().split()))
d.sort()
ans = d[int(n/2)] - d[int(n/2) - 1]
print(ans)

Submission status: Accepted

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

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

d.sort()
n = int(N/2)
print(d[n] - d[n-1])

Submission status: Accepted

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

dic = {}

for e in d :
    if e not in dic :
        dic[e] = 1
    else :
        dic[e] += 1

dic = sorted(dic.items(), key=lambda x:x[0])

#print(dic)

sum = 0
ancker = 0
tmp = 0
ans = True

for i in range(len(dic)):
    sum += dic[i][1]
    if sum == N / 2 :
        ancker = i
        break;
    if sum > N / 2 :
        ans = False
        break
#print(ancker)

if not ans :
    print(0)
else :
    print(dic[ancker+1][0] - dic[ancker][0])

Submission status: Accepted

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

d.sort()

print(d[int(N/2)]-d[int(N/2)-1])

Submission status: Accepted

Solution code:
N = int(input())
D = [int(x) for x in input().split(' ')]

DS = sorted(D)
A = DS[N//2-1]
B = DS[N//2]
AB = B - A

print(AB)

Submission status: Accepted

Solution code:
n = int(input())
q = list(map(lambda x:int(x),input().split()))
q.sort()
cnt = q[int(n/2)] - q[int(n/2)-1]
print(cnt)

Submission status: Accepted

Solution code:
n=int(input())
d=list(map(int,input().split()))
d.sort()
print(abs(d[int(n/2)]-d[int((n/2)-1)]))

Submission status: Accepted

Solution code:
N=int(input())
D=list(map(int,input().split()))
D=sorted(D)
dD=[D[0:int(N/2)],D[int(N/2):]]
print(dD[1][0]-dD[0][-1])

Submission status: Accepted

Solution code:
N = int(input())
d = sorted(list(map(int, input().split(' '))))
ret = 0
l = d[N//2 - 1]
r = d[N//2]
if l < r:
    ret = r - l   
print(ret)

Submission status: Accepted

Solution code:
n = int(input());
d = input().split(" ");
for i in range(n) :
	d[i] = int(d[i]);
d.sort();
print(d[n//2] - d[(n//2)-1]);

Submission status: Accepted

Solution code:
N = int(input())
d = list(map(int,input().split()))
d.sort()
print(d[N//2] - d[(N//2)-1])

Submission status: Accepted

Solution code:
import logging

logging.basicConfig(level=logging.INFO, format="%(message)s")
logging.disable(logging.CRITICAL)

K = int(input())
L = list(int(x) for x in input().split())

Ld = sorted(L)

if Ld[int(K / 2) - 1] == Ld[int(K / 2)]:
    print(0)
else:
    print(Ld[int(K / 2)] - Ld[int(K / 2) - 1])

Submission status: Accepted

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

d.sort()

count = d[ n//2 ] - d[n//2 - 1] 

print( count )

Submission status: Accepted

Solution code:
N = int(input()) #Nは偶数
d = list(map(int, input().split()))
cnt = 0
d.sort()
#print(d)
#print(int(N/2-1))
#print(int(N/2))
print(d[int(N/2)]- d[int(N/2-1)])

Submission status: Accepted

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

sd = sorted(d)
low = sd[N//2-1]
up = sd[N//2]
num = up - low
print(num)

Submission status: Accepted

Solution code:
N = int(input())
d = [int(i) for i in input().split()]
d = sorted(d)
mid = N//2

left = d[mid-1]
right = d[mid]

ans = 0

l = 0
for i in d:
    if i >= right:
        l += 1

if l == mid:
    ans += 1

if right != left:
    ans += right - left - 1 

print(ans)

Submission status: Accepted

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

def judge(D):  
    D.sort()
    half = int(N/2)
    
    if (N%2)==1:
        return 0
    if D[half]==D[half-1]:
        return 0
    ans = D[half]-D[half-1]
    return ans

print (judge(D))

Submission status: Accepted

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

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

# solve
ans = 0
d = sorted(d)
center = int(N / 2)
if d[center - 1] != d[center]:
    for i in range(d[center] - d[center - 1]):
        ans += 1

# output
print(ans)

Submission status: Accepted

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

dl.sort()
half = int(n / 2)
diff = dl[half] - dl[half - 1]
if diff == 0:
    print(0)
else:
    print(diff)

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
N = int(input())
d_s = list(map(int,input().split()))
d_s.sort()
print(d_s[len(d_s)//2]-d_s[len(d_s)//2-1])

Submission status: Accepted

Solution code:
N=int(input())
ld=[int(e) for e in input().split(' ')]

ld.sort()
print(ld[N//2]-ld[N//2-1])

Submission status: Accepted

Solution code:
import numpy as np
n = int(input())
li = list(map(int,input().split()))
li.sort()
arr_li = np.array(li)
if(arr_li[int(n/2)] == arr_li[int(n/2-1)]):
    print('0')
else:
    print(arr_li[int(n/2)]-arr_li[int(n/2-1)])

Submission status: Accepted

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

e=[0 for i in range(100000)]

for i in range(N):
	e[d[i]-1]=e[d[i]-1]+1

k = 0
c = 0
for i in range(100000):
	k = k + e[i]
	if k==int(N/2):
		c = c+1

print(c)

Submission status: Accepted

Solution code:
N = int(input())

d = sorted([int(x) for x in input().split()])

print(d[N//2] - d[(N//2)-1])

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
from math import factorial

N = int(int(input()) / 2)
D = sorted(list(map(int, input().split())))

print(D[N] - D[N-1])

Submission status: Accepted

Solution code:
import numpy as np

N = int(input())
arr = [int(i) for i in input().split()]
arr = np.sort(arr)
m1 = arr[int(N / 2)-1]
m2 = arr[int(N / 2)]
print(m2 - m1)

Submission status: Accepted

Solution code:
N = int(raw_input())
D = map(int, raw_input().split())
D.sort()

print(D[N/2] - D[N/2-1])

Submission status: Accepted

Solution code:
import collections

N = input()
score = input()

score = list(map(int,score.split(" ")))
sorted_num = sorted(score)

mid = int(len(sorted_num)/2)
mid_flont,mid_back = sorted_num[mid-1], sorted_num[mid]

mid_c = (mid_back - mid_flont)
if not mid_c > 0:
    print(0)
else:
    print(mid_c)

Submission status: Accepted

Solution code:

def code_for_C(test=None):

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

    list_d.sort()

    half_smaller = list_d[int(N/2)-1]
    half_larger = list_d[int(N/2)]

    print(half_larger - half_smaller)
    
code_for_C()

Submission status: Accepted

Solution code:
n = int(input())
d = list(map(int, input().split()))
count = 0

if len(d)%2!=0:
    print(count)
else:
    d = sorted(d)
    count = d[n//2]-d[n//2-1]
    print(count)

Submission status: Accepted

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

 # print(d)
a = d[int(N/2)-1]
b = d[int(N/2)]
K = b - a

print(K)

Submission status: Accepted

Solution code:
n=int(input())
d=list(map(int,input().split()))
d.sort()
N=int(n/2)
print(int(d[N])-int(d[N-1]))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
N = int(input())
d = list(map(int, str(input()).split()))

d.sort()

if d[N//2 - 1] == d[N//2]:
    output = 0
else:
    output = d[N//2] - d[N//2-1]

print(str(output))

Submission status: Accepted

Solution code:
N=int(input())
permu=list(map(lambda x:int(x),input().split()))
permu=sorted(permu)
s,t=int(N/2)-1,int(N/2)
a=list(range(permu[s]+1,permu[t]+1))
print(len(a))

Submission status: Accepted

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


if len(D) & 2 == 1: ans = 0
else:


    D = sorted(D)

    a = D[int(len(D)/2) - 1]
    b = D[int(len(D)/2)]

    ans = b - a


print(ans)

Submission status: Accepted

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

d = sorted(d)

print(d[round(len(d) / 2)] - d[round(len(d) / 2) - 1])

Submission status: Accepted

Solution code:
n = int(input())

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

wari = n//2

if n%2==1:
    print(0)
    exit()

d.sort(reverse=True)

print(d[wari-1]-d[wari])

Submission status: Accepted

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

left_max = (d[int(N/2)-1])
right_min = (d[int(N/2)])
if left_max == right_min:
    print(0)
else:
    print(right_min-left_max)

Submission status: Accepted

Solution code:
n=int(input())
D=list(map(int,input().split()))
D.sort()
i = int(n / 2) - 1
ans = D[i+1] - D[i]
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
d = list(map(int, input().split()))
d.sort()
c = (n // 2) - 1
print(d[c+1] - d[c])

Submission status: Accepted

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

s.sort()


m = n//2 -1
#print(s)
ans = 0
if s[m+1] == s[m]:
    ans = 0
else:
    ans = s[m+1]-s[m]

print(ans)
#print(m)

Submission status: Accepted

Solution code:
# ABC132C - Divide the Problems
from statistics import median_high, median_low


def main():
    n = int(input())
    D = sorted(map(int, input().rstrip().split()))
    h, l = median_high(D), median_low(D)
    print(h - l)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n= int(input())
l = list(map(int,input().split()))
l = sorted(l)
h_l = int(n/2)-1
h_r = int(n/2)
if l[h_l] == l[h_r]:
  print(0)
else:
  print(l[h_r]-l[h_l])

Submission status: Accepted

Solution code:
import re

N = int(input())
d = sorted([int(i) for i in re.split(" ", input())])

x = d[N // 2 - 1]
y = d[N // 2]

print(y - x)

Submission status: Accepted

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

def is_big(k):
    countA = 0
    countB = 0
    for i in range(n):
        if d[i] >= k:
            countA += 1
        else:
            countB += 1

    if countA >= countB:
        return True
    else:
        return False

def solve(k):
    countA = 0
    countB = 0
    for i in range(n):
        if d[i] >= k:
            countA += 1
        else:
            countB += 1

    if countA == countB:
        return True
    else:
        return False

l = 0
r = 100000
m = (l + r) // 2
#count = 0

while l <= r:
    if is_big(m):
        l = m + 1
        m = (l + r) // 2
    else:
        r = m - 1
        m = (l + r) // 2

#print(m)
#count = 0

if solve(m):
#    print('YES')
    d.sort()
    for i in range(n):
        if d[i] == m:
            print(d[i] - d[i-1])
            break

else:
    print(0)

Submission status: Accepted

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

ds = sorted(ds)
startI = int(N/2)-1
endI = startI+1
print(ds[endI]-ds[startI])

Submission status: Accepted

Solution code:
m = int(input()) // 2
a = sorted(map(int, input().split()))
print(a[m] - a[m - 1])

Submission status: Accepted

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

half = int(n/2)
xlist.sort()

a = xlist[half-1]
b = xlist[half]



ans = b-a

print(ans)

#print(xlist)
#print(a)
#print(b)

Submission status: Accepted

Solution code:
N = int(input())
D = list(map(int,input().split()))
D.sort()
i = int(N/2)
print(D[i] - D[i-1])

Submission status: Accepted

Solution code:
n=int(input())
d=list(map(int, input().split()))
sum_d=sum(d)
d=sorted(d)
answer=0
t=int(len(d)/2)
answer=d[t]-d[t-1]
print(answer)

Submission status: Accepted

Solution code:
n = int(input())
l = list(map(int, input().split()))
l.sort()
n2 = n//2
print(l[n2] - l[n2-1])

Submission status: Accepted

Solution code:
from collections import Counter
n = int(input())
p = Counter(list(map(int, input().split())))
p = sorted((x, p[x]) for x in p)

cnt = 0

if n % 2 == 0:
    s = n // 2
    pre = None
    for x, y in p:
        if p is None:
            p = x
        if s == 0:
            cnt = x - pre
            break
        s -= y
        pre = x


print(cnt)

Submission status: Accepted

Solution code:

def main():
    n=int(input())
    d=list(map(int,input().split()))

    d.sort()
    k=n//2
    
    num=d[k]-d[k-1]
    print(num)

if __name__=="__main__":
    main()

Submission status: Accepted

Solution code:
N  = int(input())
d_list = sorted(list(map(int,input().split())))
mannaka = int(N/2)
temae = d_list[mannaka -1]
saki = d_list[mannaka]

print(saki - temae)

Submission status: Accepted

Solution code:
N=int(input())
d=list(map(int,input().split()))
d.sort()
print(d[N//2]-d[(N//2)-1])

Submission status: Accepted

Solution code:
n = int(input())
num = int(n/2)
d_n = list(map(int, input().split()))
d_n.sort()

d_n_min_max = d_n[num-1]
d_n_max_min = d_n[num]

delta = d_n_max_min - d_n_min_max
print(delta)

Submission status: Accepted

Solution code:
N=int(input())
listD=list(map(int,input().split()))
listD.sort()
K=listD[N//2]-listD[N//2-1]
print(K)

Submission status: Accepted

Solution code:
N = int(input())
d = list(map(int, input().split()))
d.sort()
r = d[N // 2 ]
l = d[N // 2 - 1]
if r == l:
    print(0)
else: 
    print(r-l)

Submission status: Accepted

Solution code:
N=int(input())
L=list(map(int,input().split()))
C=0
#print(L)
L.sort()
#print(L)

#print(int(L[N//2]))
#print(int(L[N//2-1]))
print((int(L[N//2])-int(L[N//2-1])))

Submission status: Accepted

Solution code:
N = int(input())
data_list = [int(x) for x in input().split()]
data_sorted = sorted(data_list)
print(data_sorted[int(len(data_sorted)/2)] - data_sorted[int(len(data_sorted)/2 -1)])

Submission status: Accepted

Solution code:
input()
x = input()
nums = x.split()

#print(nums)

for i in range(len(nums)):
  nums[i] = int(nums[i])

nums.sort()
  
h = int(len(nums)/2)

if nums[h] == nums[h-1]:
  print("0")
  exit()

print(nums[h] - nums[h-1])

Submission status: Accepted

Solution code:
N = int(input())
d = [int(x) for x in input().split()]
d.sort()

print(d[int((N/2))] - d[int((N/2) - 1)])

Submission status: Accepted

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


res = 0

dX.sort()

if n % 2 == 0:
    res = dX[n//2] - dX[n//2-1]
print(res)

Submission status: Accepted

Solution code:
# input process
N = int(input())
inputData = input().split()
D = [int(x) for x in inputData]
D.sort()
if D[int((N/2 - 1))] == D[int((N/2))]:
    print("0")
    exit()
print(D[int((N/2))] - D[int((N/2 - 1))])

Submission status: Accepted

Solution code:
n = int(input())
lst = sorted(list(map(int, input().split())))
cnt = 0
if len(lst)%2 != 0:
  print(0)
else:
  print(lst[int(len(lst)/2)] - lst[int(len(lst)/2 - 1)])

Submission status: Accepted

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

d.sort()

print(d[int(n/2)]-d[int(n/2) -1])

Submission status: Accepted

Solution code:
n = int(input()) 
d = list(int(_) for _ in input().split()) 

d.sort()

min_ = int(n/2-1)
max_ = int(n/2)
print(d[max_]-d[min_])

Submission status: Accepted

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

if d[n // 2] - d[n // 2 - 1] == 0:
    print(0)
else:
    print(d[n // 2] - d[n // 2 - 1])

Submission status: Accepted

Solution code:
n = int(input())

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

d_sorted = sorted(d)

print(d_sorted[int(len(d_sorted)/2)] - d_sorted[int(len(d_sorted)/2 - 1)])

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sat Jun 29 20:55:57 2019

@author: YudNK
"""

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

D.sort()

l = D[0:int(N/2)]
r = D[int(N/2):]

print(r[0] - l[-1])

Submission status: Accepted

Solution code:
n = int(input())
d=input().split()
list=[]
for i in range(n):
    list.append(int(d[i]))
list.sort()
a=list[int(n/2)-1]
b=list[int(n/2)]
print(b-a)

Submission status: Accepted

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

d.sort()

min_value = d[len(d) // 2 - 1]
max_value = d[len(d) // 2]

print(max_value - min_value)

Submission status: Accepted

Solution code:
def li():
    return list(map(int, input().split()))


if __name__ == "__main__":
    n = int(input())
    d_list = li()

    d_list.sort()
    print(d_list[n // 2] - d_list[n // 2 - 1])

Submission status: Accepted

Solution code:
N=int(input())

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

d.sort()

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

print(b-a)

Submission status: Accepted

Solution code:
n = int(input())
a = sorted(map(int, input().split()))
print(a[n // 2] - a[n // 2 - 1])

Submission status: Accepted

Solution code:
def main():
    N = int(input())
    *D, = map(int, input().split())

    m = N // 2
    D = sorted(D)

    print(D[m] - D[m-1])


main()

Submission status: Accepted

Solution code:
N = int(input())
d = list(map(int, input().split()))
count = 0
d.sort()
print(d[N//2]-d[N//2-1])

Submission status: Accepted

Solution code:
N = int(input())
d = list(map(int,input().split()))
d.sort()
#print(d)
half = int(N/2)
dis = d[half] - d[half - 1]
print(dis)

Submission status: Accepted

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

print(d[n // 2] - d[n // 2 - 1])

Submission status: Accepted

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

qnum = len(diff_l)
if(qnum%2!=0):
    print(0)
else:
    print(diff_l[int(qnum/2)]-diff_l[int(qnum/2-1)])

Submission status: Accepted

Solution code:
import numpy as np

N = int(input())
a = input().split(" ")
d = [int(i) for i in a]
d.sort()
a = d[int(N/2)-1]
b = d[int(N/2)]
print(b-a)

Submission status: Accepted

Solution code:
n=int(input())
d=sorted([int(i) for i in input().split()])
dif=[0]*d[-1]
ruiseki=[0]*d[-1]
for i in d:
    dif[i-1]+=1
for i in range(d[-1]):
    ruiseki[i]=ruiseki[i-1]+dif[i]
SUM=sum(dif)
ans=0
for i in range(n-1):
    S=ruiseki[d[i]-1]
    if S==SUM-S:
        ans+=d[i+1]-d[i]
print(ans)

Submission status: Accepted

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

if d_sorted[N//2-1] == d_sorted[N//2]:
  print(0)
else:
  print(d_sorted[N//2] - d_sorted[N//2-1])

Submission status: Accepted

Solution code:
# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

readl= lambda: list(map(int, sys.stdin.readline().split()))
readt= lambda: tuple(map(int, sys.stdin.readline().split()))
read = lambda: sys.stdin.readline().rstrip()
readi = lambda: int(read())
readmi = lambda: map(int, sys.stdin.readline().split())
readms = lambda: map(str, sys.stdin.readline().split())

n = readi()
h = readl()
h.sort()
left = h[n // 2 - 1]
right = h[n // 2]
print(right - left)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
import collections
import bisect

def main():
	#A, B, Q = map(int, input().split(" "))
	N = int(input())
	d = list(input().split(" "))
	d = [int(s) for s in d]
	d.sort()
	base = (len(d))//2
	
	ans = 0
	for k in range(d[0]-1, d[-1]+2):
		tmp = bisect.bisect_left(d,k)
		if tmp == base:
			ans+=1
	
	print(ans)	
	
	
if __name__ == "__main__":
	main()

Submission status: Accepted

Solution code:
N = int(raw_input())
S = map(int, raw_input().split(' '))

S.sort()

minn = S[N/2-1]
maxn = S[N/2]

print(max(0, maxn-minn))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
N = map(int, input().split())
L = list(map(int,input().split()))

L.sort()
med1 = len(L)//2 -1
med2 = len(L)//2
if L[med1] == L[med2]:
  print(0)
else:
  print(L[med2] - L[med1])

Submission status: Accepted

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

med_low = statistics.median_low(d_ls)
med_high = statistics.median_high(d_ls)
if med_low == med_high and d_ls.count(med_low)==1:
    ans = 1
else:
    ans = med_high - med_low
    
print(ans)

Submission status: Accepted

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

d.sort()

print(d[len(d)//2] - d[len(d)//2-1])

Submission status: Accepted

Solution code:
import numpy as np

n = int(input())
d = np.array(sorted((list(map(int, input().split())))))

if len(d[d <= d[n // 2 - 1]]) == n // 2:
    print(d[n // 2] - d[n // 2 - 1])
else:
    print(0)

Submission status: Accepted

Solution code:
N = int(input())
d = list(map(int,input().split()))
#リストを小さい順に並べる
list.sort(d)
print(d[N//2]-d[N//2-1])

Submission status: Accepted

Solution code:
N = int(input())
d = list(map(int, input().split()))
d.sort()
diff = d[N//2] - d[N//2-1]
print(diff)

Submission status: Accepted

Solution code:
n = int(input())
d = list(map(int,input().split()))
d = sorted(d)
length = len(d) // 2
max = d[length]
min = d[length - 1]
print(max - min)

Submission status: Accepted

Solution code:
n=int(input())
d=sorted(list(map(int,input().split())))
#print(d)
res=0
if n % 2 == 0:
    m=int(n/2)
    #print(d[m],d[m+1])
    if d[m-1] == d[m]:
        pass
    else:
        res = d[m] - d[m-1] 

else:
    pass
    
    
print(res)

Submission status: Accepted

Solution code:
n = int(input())
S = list(map(int,input().split()))
p = sorted(S)
print(p[int(n/2)] - p[int((n/2)-1)])

Submission status: Accepted

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

n = int(N/2) - 1

a = d[n]
b = d[n + 1]

print(b - a)

Submission status: Accepted

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

tbl = [0] * (mx+1)
for i in ds:
    tbl[i] += 1

cnt = 0
res = 0
for i in range(max(ds)):
    cnt += tbl[i]
    if cnt == n//2:
        res += 1
    elif cnt > n//2:
        break

print(res)

Submission status: Accepted

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

Submission status: Accepted

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

L.sort()
H = int(N/2)
A = L[H] - L[H-1]
if A > 0:
    print(A)
else:
    print(0)

Submission status: Accepted

Solution code:
N = int(input())
d = [int(i) for i in input().split()]
d = sorted(d)
if d[N//2] == d[N//2-1]:
    ans = 0
else:
    ans = d[N//2] - d[N//2-1]
print(ans)

Submission status: Accepted

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

sort_D = sorted(D)
mid = int(n / 2)
max_easy = sort_D[mid - 1]
min_difc = sort_D[mid]
print(min_difc - max_easy)

Submission status: Accepted

Solution code:
n = int(input())

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

d = sorted(d)
a = d[int(n/2)]
b = d[int(n/2 - 1)]
print(a-b)

Submission status: Accepted

Solution code:
n = int(input())
nums = list(map(int, input().split()))
nums.sort()
topIndex = int(len(nums) / 2)
underIndex = topIndex - 1
print(nums[topIndex] - nums[underIndex])

Submission status: Accepted

Solution code:
N = int(input())
d = list(map(int,input().split()))
d.sort()
a=N//2-1
b=N//2
if d[a] == d[b]:
  print(0)
else:
  ans = d[b]-d[a]
  print(ans)

Submission status: Accepted

Solution code:
N=int(input())
D=list(map(int,input().split()))
DD=sorted(D)
print(DD[N//2]-DD[N//2-1])

Submission status: Accepted

Solution code:
N = int(input())
d = [int(x) for x in input().split(' ')]
d.sort()
# print(d)
print(d[int((N/2))]-d[int(N/2)-1])

Submission status: Accepted

Solution code:
n=int(input())
s=sorted(list(map(int,input().split())))
m=int(n/2)

print(s[m]-s[m-1])

Submission status: Accepted

Solution code:
N = int(input())
d = list(map(int, input().split()))
d.sort()
num = N//2-1
print(d[num+1]-d[num])

Submission status: Accepted

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

print(d[n//2] - d[n//2 - 1])

Submission status: Accepted

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

N = int(sysinput())
d = [x for x in map(int, sysinput().split())]

d = sorted(d)
ans = d[int(N/2)] - d[int(N/2-1)]
print(ans)

Submission status: Accepted

Solution code:
from statistics import mean, median,variance,stdev
from collections import  Counter
n =int(input())
D = sorted(list(map(int,input().split())))
med = int(median(D))
middle = D[n//2+1 if n%2==1 else n//2 ]
if med >=middle:
	print(0)
else:
	print(D[(n//2+1 if n%2==1 else n//2)]-D[(n//2+1 if n%2==1 else n//2)-1])

Submission status: Accepted

Solution code:
n = int(input())
d = list(map(int, input().split()))
ans = 0
d.sort()
low = d[:len(d)//2][-1]
high = d[len(d)//2:][0]

print(high - low)

Submission status: Accepted

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

d.sort()

if n % 2 == 1:
  print(0)
else:
  print(d[n//2] - d[n//2 - 1])

Submission status: Accepted

Solution code:
if __name__ == '__main__':
  n = int(input())
  d = list(map(int, input().split(" ")))
  d.sort()
  div_idx = n // 2
  print(d[div_idx] - d[div_idx - 1])

Submission status: Accepted

Solution code:
"""
# 標準入力取得
## 文字列
 = sys.stdin.readline().rstrip()
 = list(sys.stdin.readline().rstrip())

## 数値
 = int(sys.stdin.readline())
 = map(int, sys.stdin.readline().split())
 = list(map(int, sys.stdin.readline().split()))
 = [list(map(int,list(sys.stdin.readline().split()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき

# 0埋め, 小数点出力桁指定時のときの出力
a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654

# 文字列をリストに格納
char_list = list("abcd") # ["a","b","c","d"]
"""

import math
import sys
import itertools
import queue
from fractions import gcd

def lcm(a, b):
    return a * b // gcd(a, b)

mod = 1000000007

if __name__ == "__main__":
    n= int(sys.stdin.readline())
    d= list(map(int, sys.stdin.readline().split()))
    d.sort()
    h=int(n/2)
    dz=d[:h]
    dk=d[h:]
    dz_max=max(dz)
    dk_min=min(dk)
    c=0
    print(dk_min-dz_max)

Submission status: Accepted

Solution code:
N = int(input())
nums = str(input()).split(' ')
nums = sorted([int(n) for n in nums])

a = nums[len(nums) // 2 - 1]
b = nums[len(nums) // 2]

aida = b - a
cnt = 0
for i in range(aida + 1):
    if a < a + i and a + i <= b:
        cnt += 1

print(cnt)

Submission status: Accepted

Solution code:
# C - Divide the Problems

N = int(input().rstrip())
d_s = input().split(" ")

d = [int(s) for s in d_s]
d.sort()
print(d[int(N/2)]-d[int(N/2-1)])

Submission status: Accepted

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

msort = sorted(m)
div = n//2
print(msort[div] - msort[div-1])

Submission status: Accepted

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

abc = C[int(N/2-1)]
arc = C[int(N/2)]

print(arc-abc)

Submission status: Accepted

Solution code:

import sys
input = sys.stdin.readline
#-------------------------------------
n = int(input())
d = list(map(int,input().split()))

d = sorted(d)

ans = d[int(n/2)] - d[int(n/2)-1]

print(ans)

Submission status: Accepted

Solution code:
import numpy as np

N = int(input())
D = input()
D =  D.split(' ')
D = [int(d) for d in D]
D_sort = np.sort(D)

k = int(N/2)
count = 0

low_d = D_sort[k-1]
hight_D = D_sort[k]
dis = hight_D - (low_d+1) + 1

print(dis)

Submission status: Accepted

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

d.sort()

l = (n//2) -1
r = (n//2)

print(d[r]-d[l])