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())
d = list(map(int, input().split()))
d.sort()
print(d[n//2]-d[n//2-1])

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys


def solve(N: int, d: "List[int]"):
    d.sort()
    abc = d[int(N/2)-1]
    arc = d[int(N/2)]
    print(arc-abc)

    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    d = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, d)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys


def solve(N: int, d: "List[int]"):
    b = [0] * (10**5 +1)
    for i in range(N):
        b[d[i]] += 1
    t = 0
    f = False
    ans = 0
    for i in range(1, 10 ** 5 + 1):
        if not f:
            t += b[i]
            if t == N / 2:
                f = True
            elif t > N / 2:
                ans = 0
                break
        else:
            ans += 1
            if b[i] != 0:
                break
    print(ans)



    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    d = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, d)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys


def main():
    input = sys.stdin.buffer.readline
    n = int(input())
    d = sorted((map(int, input().split())))
    print(d[n // 2] - d[n // 2 - 1])


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
n = int(input())
d = list(map(int,input().split()))
d.sort()
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()))

d.sort()

# Odd pattern
if n % 2 == 1:
    print(0)
# Even pattern
else:
    ml = int(n / 2) - 1
    mr = int(n / 2)
    if d[ml] == d[mr]:
        print(0)
    else:
        print(d[mr] - d[ml])

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n = int(input())
L = sorted(list(map(int,input().split())))
c = n // 2
print(L[c]-L[c-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:
a = input()
N = int(a)
d = list(map(int,input().split()))

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

Submission status: Accepted

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

ans = ary[int(len(ary)/2)] - ary[int(len(ary)/2) -1]
print(ans)

Submission status: Accepted

Solution code:
N = int(input())
d = list(map(int, input().split()))
d = sorted(d)
if N % 2 != 0:
  print(0)
else:
  x = N // 2
  ans = d[x] - d[x-1]
  print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

dlist_sorted = sorted(dlist)

kiwa_upper = dlist_sorted[n//2]
kiwa_low = dlist_sorted[(n//2)-1]

# 同じ数の選び方が存在しない場合
if len(dlist_sorted[n//2:]) != n//2:
    print(0)
# 存在する場合
else:
    print(kiwa_upper - kiwa_low)

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())
d = sorted(list(map(int,input().split())))

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

Submission status: Accepted

Solution code:
n=int(input())
d=[int(x) for x in input().split()]
if n%2==1:
    print(0)
    exit()
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()

s = int(len(d)/2)

if d[s] != d[s-1] :
    print(d[s]-d[s-1])
elif d[s] == d[s-1] :
    print(0)

Submission status: Accepted

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

Submission status: Accepted

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

half = N//2
d.sort()

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

Submission status: Accepted

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

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

d.sort()
i1 = N // 2
i2 = N // 2 - 1

result = d[i1] - d[i2]
print(result)

Submission status: Accepted

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

half = n//2
first = d[half - 1]
second = d[half]

print(second - first)

Submission status: Accepted

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


# N/2番目に難しい問題が「ARC用の問題」かつ、
# N/2−1番目に難しい問題が「ABC用の問題」であればよい
# 難易度順に昇順でソート
# N/2番目の要素から、N/2−1番目の要素を引く

# 例d=[1,5,9,11,13,15,19,20]なら、答えは12,13の2つ
d = sorted(d)
print(d[N//2] - d[(N//2)-1])

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

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

Submission status: Accepted

Solution code:
# AtCoder Beginner Contest 132
# C - Divide the Problems

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

d.sort()

l=d[(N//2)-1]
r=d[(N//2)]
if l==r:
    print(0)
    exit()

print(r-l)

# print(d)
# print(l,r)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8

def main():
    N = int(input())
    d = sorted(list(map(int, input().split())))
    ans = 0
    if d[N // 2] != d[N // 2 - 1]:
        ans = d[N // 2] - d[N // 2 - 1]

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Thu Sep 10 14:46:16 2020

@author: liang
"""

N = int(input())
d = [int(x) for x in input().split()]
d.sort()
ans = d[N//2] - d[N//2 - 1 ]
print(ans)

Submission status: Accepted

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

K_cnt = 0
dsort = sorted(d)

d_left = dsort[int(N/2)-1]
d_right = dsort[int(N/2)]

# ソートして中央値が一致した場合
# ぴったり同じにならない
if d_left == d_right:
    print(0)
else:
    print(d_right-d_left)

Submission status: Accepted

Solution code:
N, *D = map(int, open(0).read().split())

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# C
import math
N = int(input())
D = sorted(list(map(int, input().split())))
print(D[math.ceil((N)/2)] - D[math.ceil((N)/2)-1])

Submission status: Accepted

Solution code:
import math
import statistics
a=int(input())
#b=int(input())
# c=[]
# for i in b:
#     c.append(i)
# e1,e2 = map(int,input().split())
f = list(map(int,input().split()))
#j = [input() for _ in range(3)]
# h = []
# for i in range(e1):
#     h.append(list(map(int,input().split())))
f.sort()
tyu = statistics.median(f)
if f[len(f)//2]==f[len(f)//2-1]:
    print(0)
else:
    print(f[len(f)//2]-f[len(f)//2-1])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline

def main():
    exams=[]
    sorted_exams=[]
    n = int(input())
    exams=list(map(int,input().split()))
    sorted_exams=sorted(exams)
    half=n//2

    start=sorted_exams[half-1]
    end=sorted_exams[half]

    print(end-start)

if __name__=="__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
d = [int(x.strip()) for x in input().split()]
d_sorted = sorted(d)
m = int(n/2)
abc_fin = d_sorted[m-1]
arc_start = d_sorted[m]
if abc_fin == arc_start:
  ans = 0
else:
  ans = arc_start - abc_fin
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
d =list(map(int,input().split()))
d.sort()
ans = 0
for i in range(1,10**5+1):
        if d[n//2-1] <i and d[n//2] >=i:
                ans +=1

print(ans)

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())
d = sorted(list(map(int, input().split())))

x = d[n//2-1]
y = d[n//2]
print(y-x)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# C - Divide the Problems
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())
D = list(map(int,input().split()))
D.sort()
a = D[n//2]
b = D[n//2-1]
print(a-b)

Submission status: Accepted

Solution code:
N = int(input())
d = sorted(list(map(int,input().split())))
if len(d) % 2 !=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.sort()

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

Submission status: Accepted

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

if len(d) % 2 == 1:
  print(0)
  exit(0)
  
pick = len(d)//2
ans = d[pick] - d[pick-1]
print(ans)

Submission status: Accepted

Solution code:
n = int(input())
d = [int(i) for i in input().split()]
d.sort()
r = d[int(n/2)]
l = d[int(n/2)-1]
if r == l :
  print(0)
else :
  print(r-l)

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())
d=list(map(int, input().split()))
d.sort()
l=n//2
print(d[l]-d[l-1])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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:
#ネットのやつ　自分で考える
#from math import ceil
#n, h = map(int, input().split( ))
N = int(input())
D = list(map(int, input().split( )))
D1 = sorted(D)
n = N//2
print(D1[n] - D1[n-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:
N = int(input())
d = list(map(int, input().split()))
d = sorted(d)

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()))
d = sorted(d)

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

print(0 if x == y else y-x)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import numpy as np

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

med = np.median(d)
if med in d:
  print(0)
  
else:
  lar = [x for x in d if x>med]
  sma = [x for x in d if x<med]

  print(lar[0]-sma[-1])

Submission status: Accepted

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

List.sort()
divideNum=N//2
print(List[divideNum] - List[divideNum-1])

Submission status: Accepted

Solution code:
N = int(input())
N_List = sorted(list(map(int,input().split())))
std = int(N/2)
ansstd = N_List[std] - N_List[std-1] 
print((0,ansstd)[ansstd > 0])

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n = int(input())
Ds = list(map(int, input().split()))
L1 = [0] * (10 ** 5 + 1)
L2 = [0] * (10 ** 5 + 1)
for d in Ds:
  L1[d] += 1
L2[0] = L1[0]
for i in range(1,10 ** 5 +1):
  L2[i] = L1[i] + L2[i - 1]
print(L2.count(n //2))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a=int(input())
b=list(map(int,input().split()))
"""
import statistics
import math
median = statistics.median(b) 中央値出そうとした
print(median)
"""
b.sort()
c=int(a/2)
print(b[c]-b[c-1])

Submission status: Accepted

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

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())//2
a= list(map(int,input().split()))
a=sorted(a)
print(a[n]-a[n-1])

Submission status: Accepted

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

print(d2-d1)

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())
d=list(map(int,input().split()))
d.sort()
sum=d[N//2]-d[N//2-1]
print(sum)

Submission status: Accepted

Solution code:
n=int(input())
d=[int(x) for x in input().split()]
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:
def main():
    n = int(input())
    d = list(map(int, input().split()))

    sort_d = sorted(d)

    median_index = int(n/2)

    median_d = sort_d[median_index]
    median_d_minus1 = sort_d[median_index-1]

    answer = median_d - median_d_minus1
    print(answer)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

    d_lst.sort()

    ans = d_lst[n // 2] - d_lst[n // 2 - 1]

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

    d_lst.sort()

    if d_lst[n // 2 - 1] == d_lst[n // 2]:
        ans = 0
    else:
        ans = d_lst[n // 2] - d_lst[n // 2 - 1]

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def mapt(fn, *args):
    return tuple(map(fn, *args))


def Input():
    return mapt(int, input().split(" "))


def main():
    n = int(input())
    a = Input()
    sorted_a = sorted(a)
    point = max(a)//2
    center_index = len(a)//2
    right = sorted_a[center_index:]
    left = sorted_a[:center_index]
    print((point) - max(left) + min(right)-point)



main()

Submission status: Accepted

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

Submission status: Accepted

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

def main():
    lines = input()

    n = int(lines[0].strip())
    a = list(map(int, lines[1].split()))

    a = sorted(a)
    c = a[n//2 - 1] ; d = a[n//2]

    print(d-c)

main()

Submission status: Accepted

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

lev_s = sorted(lev)
ans = 0

if lev_s[n//2] == lev_s[n//2 - 1]:
  print(0)
else:
  print(abs(lev_s[n//2] - lev_s[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 sys
from collections import deque
import numpy as np
import math
sys.setrecursionlimit(10**6)
def S(): return sys.stdin.readline().rstrip()
def SL(): return map(str,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def IL(): return map(int,sys.stdin.readline().rstrip().split())

def solve():
    mid = n//2
    print(d[mid]-d[mid-1])
    return

if __name__=='__main__':
    n = I()
    d = sorted(list(IL()))
    solve()

Submission status: Accepted

Solution code:
N = int(input())
d = sorted(list(map(int, input().split())))
if d[int(N/2)-1] == d[int(N/2)]:
  print(0)
else:
  
  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_s = sorted(d)
k = d_s[n//2] - d_s[n//2-1]
print(k)

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())
d=list(map(int,input().split()))

d.sort()

th1 = d[N//2-1]
th2 = d[N//2]

print(th2 - th1)

Submission status: Accepted

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

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

Submission status: Accepted

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

M = N//2
ans = D[M] - D[M-1]

if D[M] == D[M-1]:
  ans = 0

print(ans)

Submission status: Accepted

Solution code:
N=int(input())
d=list(map(int,input().split()))
d_sort=sorted(d,reverse=False)
if d_sort[N//2]==d_sort[N//2-1]:
    print('0')
else:
    print(d_sort[N//2]-d_sort[N//2-1])

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
import numpy as np
import numba
from numba import jit

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

@jit
def main(n, d):
  d_sort = np.sort(d)
  num = len(d_sort)//2
  return d_sort[num]-d_sort[num-1]


n = int(readline())
d = np.array(readline().split(), np.int64)


print(main(n, d))

Submission status: Accepted

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

abc = d[:l//2]
arc = d[l//2:]

if abc[-1] == arc[0]:
    print(0)
    exit()
    
print(arc[0] - abc[-1])

Submission status: Accepted

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

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

Submission status: Accepted

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

difficulties.sort()
first_half = difficulties[:int(n/2)]
second_half = difficulties[int(n/2):]

ans = second_half[0] - first_half[-1]

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

num=int(n/2)
if l[num]==l[num-1]:
  print(0)
else:
  print(l[num]-l[num-1])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter,defaultdict
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq
sys.setrecursionlimit(10**6)
# INF =  float("inf")
INF = 10**18
import bisect
import statistics
mod = 10**9+7
# mod = 998244353

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

d = sorted(d)

m = d[N//2-1]
M = d[N//2]
print(M-m)

Submission status: Accepted

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

sorted_D = sorted(D)

f = N//2 - 1
s = f + 1

print(sorted_D[s]-sorted_D[f])

Submission status: Accepted

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

Submission status: Accepted

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

sort_d = sorted(d)

abc = sort_d[N//2-1]
arc = sort_d[N//2]

print(arc-abc)

Submission status: Accepted

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

Submission status: Accepted

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

d.sort()

a=d[n//2]
b=d[n//2-1]

if a==b:
  print('0')

else:
  print(a-b)

Submission status: Accepted

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

N = int(input())
A = list(map(int, input().split()))
A.sort()
print(A[N//2]-A[N//2-1])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# 問題：https://atcoder.jp/contests/abc126/tasks/abc132_c

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

d = sorted(d)
res = d[n//2] - d[n//2-1]
print(res)

Submission status: Accepted

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

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N=I()
    d=LI()
    d.sort()
    a=d[N//2-1]
    b=d[N//2]
    ans=b-a
    print(ans)

main()

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()
ans = d[n//2] - d[n//2-1]

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=int(input())
d=sorted([int(i)for i in input().split()])
res=d[n//2]-d[n//2-1]
print(res)

Submission status: Accepted

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

d = sorted(d)

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

else:
    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()
print(D[N//2]-D[N//2 - 1])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
  N = int(input())
  if N % 2 == 1:
    print(0)
    return 0
  
  num = int(N/2)
  D = list(map(lambda d: int(d), input().split(" ")))
  D.sort()
  
  difficultABC = D[int(N/2) - 1]
  easyARC = D[int(N/2)]
# difficultABC < K <= easyARC
  print(easyARC - difficultABC)

main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
D = list(map(int, input().split()))
SD = sorted(D)
m = N // 2
print(SD[m] - SD[m - 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(map(int,input().split()))
d.sort()

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

Submission status: Accepted

Solution code:
def dividek(arr, n):
	arr.sort()
	return arr[n//2] - arr[(n//2)-1]
n = int(input())
arr = list(map(int, input().split()))
print(dividek(arr, n))

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import math
from math import gcd
INF = float("inf")

import sys
input=sys.stdin.readline
import itertools
from collections import Counter

def main():
    n = int(input())
    d = list(map(int, input().split()))
    d.sort()
    mid = n//2-1
    left = d[mid]
    right = d[mid+1]
    print(right-left)


if __name__=="__main__":
    main()

Submission status: Accepted

Solution code:
import bisect,collections,copy,heapq,itertools,math,string
from collections import defaultdict as D
from functools import reduce
import numpy as np
import sys
import os
from operator import mul

sys.setrecursionlimit(10**7)

def _S(): return sys.stdin.readline().rstrip()
def I(): return int(_S())
def LS(): return list(_S().split())
def LI(): return list(map(int,LS()))

if os.getenv("LOCAL"):
    inputFile = basename_without_ext = os.path.splitext(os.path.basename(__file__))[0]+'.txt'
    sys.stdin = open(inputFile, "r")
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353    

N = I()
d = LI()

d.sort()

ans = d[N//2]-d[N//2-1]

# print(d)
print(ans)

Submission status: Accepted

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

d_sort = sorted(d)
d_med1 = d_sort[len(d)//2-1]
d_med2 = d_sort[len(d)//2]
print(d_med2-d_med1)

Submission status: Accepted

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

D.sort()
ans = D[n//2]-D[n//2-1]
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N=int(input())
D=list(map(int,input().split()))
D.sort()
n=N//2
print(D[n]-D[n-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])