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())
ds = list(map(int, input().split()))
ds = sorted(ds)
mid = N // 2 # N is even
print(ds[mid] - ds[mid-1])

Submission status: Accepted

Solution code:
s = int(input())
l = list(int(x) for x in input().split())
cnt = 0
l.sort()
#print(l[len(l)//2-1])
#print(l[len(l)//2])
#print(l[len(l)//2-1]+1)
#print(l[len(l)//2]+1)
if l[len(l)//2-1] == l[len(l)//2]:
  print(0)
  exit()
for i in range((l[len(l)//2-1]+1),l[len(l)//2]+1):
  cnt += 1
print(cnt)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
''' 
------------------------
author : iiou16
------------------------
'''

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

    p_list = sorted(p_list)
    f = p_list[int(N/2 - 1)]
    c = p_list[int(N/2)]

    print(c - f)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

abc = D[:l]
arc = D[l:]

print(min(arc) - max(abc))

Submission status: Accepted

Solution code:
#!/usr/bin/python3

import sys

def solve(input_):
    input_.sort()
    min_ = input_[len(input_) // 2 - 1]
    max_ = input_[len(input_) // 2]
    return max_ - min_

def main():
    sys.stdin.readline()
    inputs = [int(s) for s in sys.stdin.readline().rstrip().split(" ")]
    print(solve(inputs))

main()

Submission status: Accepted

Solution code:
def solve():
    N = int(raw_input())
    d = [int(_) for _ in raw_input().split()]
    d.sort()
    mid = N // 2
    ret = d[mid] - d[mid-1]
    print ret

if __name__ == '__main__':
    solve()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

sd = sorted(d)

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

Submission status: Accepted

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

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

Submission status: Accepted

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

if d[center - 1] != d[center]:
    ans = d[center] - d[center - 1]
else:
    ans = 0

print(ans)

Submission status: Accepted

Solution code:
N = int(input())

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

lst.sort()
middle = int(len(lst) / 2)

if(lst[middle] == lst[middle-1]):
  print(0)
else:
  print(lst[middle] - lst[middle-1])

Submission status: Accepted

Solution code:
import fractions
from collections import deque
import numbers as np


def main():
    N = int(input())
    d = list(map(int, input().split()))
    d.sort()
    bi_m = d[(N-1)//2]
    bi_p = d[(N-1)//2 + 1]
    print(bi_p - bi_m)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
# abc132/abc132_c
import sys

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    N = i2n()
    d = i2nn()
    d.sort()
    before_half = d[int(N / 2 - 1)]
    after_half = d[int(N / 2)]
    print(after_half - before_half)
    return

main()

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline


def main():
    n = int(input())
    d = [int(i) for i in input().split()]
    d.sort()

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


if __name__ == "__main__":
    main()

Submission status: Accepted

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

d.sort()

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
n=int(input())
d=input().split(" ")
for i in range(n):
    d[i]=int(d[i])

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

m = n//2
d = sorted(d)

if d[m-1] - d[m] == 0:
    print(0)
else:
    print(abs(d[m-1] - d[m]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
lst = sorted([int(x) for x in input().split()])
a = lst[(N - 1)// 2]
b = lst[N// 2]
if a == b:
    print(0)
else:
    print(b - a)

Submission status: Accepted

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

dat.sort()

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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:
"""
# 標準入力取得
## 文字列
 = 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())
    l = list(map(int, sys.stdin.readline().split()))

    l.sort()

    length = len(l)
    if (length % 2 == 1):
        print(0)
        exit()

    pre = int(length / 2 - 1)
    post = int(length / 2)

    print(l[post] -l[pre])

Submission status: Accepted

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

Submission status: Accepted

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

d_sorted = sorted(d)

start = d_sorted[int(N/2)-1]
end   = d_sorted[int(N/2)]

res = end - start

print(res)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
from collections.abc import Iterable
from math import *
from itertools import *
from collections import *
from functools import *
from operator import *
try:
    from math import gcd
except Exception:
    from fractions import gcd


def solve(N: int, d: "List[int]"):
    d = sorted(d)
    hi = N // 2
    return d[hi] - d[hi - 1]


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]"
    result = solve(N, d)
    if isinstance(result, Iterable) and not isinstance(result, str):
        result = '\n'.join([str(v) for v in result])
    print(result)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!

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

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

Submission status: Accepted

Solution code:

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

#print(di)
ans=0
sumd=len(di)
dis=sorted(di)
#print(dis)
#print(N)

print(dis[int(N/2+1-1)]-dis[int(N/2-1)])

Submission status: Accepted

Solution code:
n1 = int(input())

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

n2.sort()

n3 = n2[(n1 // 2)] - n2[(n1 // 2) - 1]

print(n3)

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

Submission status: Accepted

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

print a[n / 2] - a[n / 2 - 1]

Submission status: Accepted

Solution code:
N = int(input())
d = sorted([int(c) for c in 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()
half = n // 2
abc = d[half - 1]
arc = d[half]
if abc == arc:
    print(0)
else:
    print(arc-abc)

Submission status: Accepted

Solution code:
num = int(input())
in_list = list(map(int, input().split()))

sorted_list = sorted(in_list)

print(sorted_list[int(num / 2)] - sorted_list[int(num / 2) - 1])

Submission status: Accepted

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

d.sort()

a = (int)((n/2) - 1)
b = (int)(n/2)

ans = d[b] - d[a]
print(ans)

Submission status: Accepted

Solution code:
from sys import stdin

n = int(stdin.readline().rstrip())
an = list(map(int, input().split()))

an.sort()

l = len(an)
h = l//2

#print(an,l,h,an[h-1],an[h])#

ans = an[h] - an[h-1]

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
l = list(map(int, input().split()))
l.sort()
#print(n,l)

x = 0#半分の境目のindex
y = 0#判定用
if n%2 == 0:
  x = n//2 - 1
else:
  y = 1
#print(x,y)

ans = 0
if y == 0:
  ans = l[x+1] - l[x]
print(ans)

Submission status: Accepted

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

D.sort()

mid = int(N/2)
if D[mid - 1] == D[mid]:
    print(0)
else:
    print(D[mid] - D[mid-1])

Submission status: Accepted

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

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

Submission status: Accepted

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

min = d[n//2-1]
max = d[n//2]

print((max-(min+1))+1)

Submission status: Accepted

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

Submission status: Accepted

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

Dsorted = sorted(D)

l = Dsorted[N//2-1]
r = Dsorted[N//2]

print(r-l)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
N = int(input())
huga = input().split()
d = []
for i in range(N):
  d.append(int(huga[i]))
  
hage = sorted(d)
print(abs(hage[int(N/2)] - hage[int(N/2) - 1]))

Submission status: Accepted

Solution code:
N = int(input())

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

inp.sort()

d = int(N / 2)

ans = inp[d] - inp[d - 1]

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

n = int(input())
s = [int(c) for c in input().split(' ')]

if len(s) % 2 == 1:
    print(0)
    exit()

s_sorted = sorted(s)

#print(s_sorted[n//2-1], s_sorted[n//2],\
#    s_sorted[n//2] - s_sorted[n//2-1])
print(s_sorted[n//2] - s_sorted[n//2-1])

Submission status: Accepted

Solution code:
N = int(input())

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

d.sort()

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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:
import bisect

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

dlist.sort()

inta = dlist[(N // 2) - 1]
intb = dlist[(N // 2)]

ans = intb - inta
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

# ソートする
sd = sorted(d)

# 長さは偶数なので、ちょうど２分できる数値が存在する
mid = int(len(sd)/2)

# ソートされた配列を、２分する値で分割し、小さい方(l)の最大値と大きい方(r)の最小値を求める
l_max = sd[mid-1]
r_min = sd[mid]

print(r_min - l_max)

Submission status: Accepted

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

D.sort()

end = N // 2
start = (N // 2) - 1

print(len(range(D[start]+1, D[end]+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 = list(map(int, input().split()))

d.sort()

a = n // 2
b = a - 1

print(d[a] - d[b])

Submission status: Accepted

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

Submission status: Accepted

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

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

sorted_d = sorted(d)

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

print(ans)

Submission status: Accepted

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

ans = 0
med = int(len(d) / 2)
if d[med - 1] != d[med]:
    ans += d[med] - d[med - 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:
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())
li = list(map(int,input().split()))
cnt = 0
li.sort()
if len(set(li)) == 1:
        cnt = 0
elif li[int(n/2 - 1)] == li[int(n/2)]:
        cnt = 0
else:
        cnt = li[int(n/2)] - li[int(n/2 -1)]
print(cnt)

Submission status: Accepted

Solution code:
n = int(input())
if n % 2 != 0:
    print(0)

l = list(map(int, input().split()))
l.sort()
print(l[n // 2] - l[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, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy,copy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd


def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def main():
    n=INT()
    d=LIST()
    d.sort()

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

if  __name__=='__main__':
    main()

Submission status: Accepted

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

d.sort()
#print(d)

mid = N // 2

if(d[mid - 1] == d[mid]):
    count = 0
else:
    count = d[mid] - d[mid - 1]

print(count)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
n = int(input())
a = int(n/2)
l = [int(i) for i in input().split()]
l.sort()
print(l[a]-l[a-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.sort()
# print(d)
this = 0
# 奇数
if n % 2 == 1:
    this = n % 2 + 1
    answer=d[this+1]-d[this]
# 偶数
else:
    this=n//2
    answer=d[this]-d[this-1]

print(answer)

Submission status: Accepted

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

L=sorted(L)

if(N%2==0):
	low_K = N//2-1
	if(L[low_K]!=L[low_K+1]):
		print(L[low_K+1]-L[low_K])
	else:
		print(0)
else:
	print(0)

Submission status: Accepted

Solution code:

def input_from_console():
    n = int(input().strip())
    d_list = list(map(int, input().strip().split()))
    return n, d_list


def solve(n, d_list):
    result = 0
    divider = n //2
    d_list.sort()
    pre = d_list[:divider]
    lower = max(pre) + 1
    post = d_list[divider:]
    upper = min(post)
    if lower <= upper:
        result = upper - lower + 1
    return result


def main():
    n, d_list = input_from_console()
    print(solve(n, d_list))


if __name__ == "__main__":
    import sys

    if sys.gettrace():  # Check if the python interpreter is in debug mode or not.
        check_cases()
    else:
        main()

Submission status: Accepted

Solution code:
N = int(input())
d = list(map(int,input().split()))
#N = 14
#d = [99592,10342,29105,78532,83018,11639,92015,77204,30914,21912,34519,80835,100000,1]
d.sort()
m = d[N//2-1]
M = d[N//2]
ans = 0
if m == M:
    ans = 0
else:
    ans = M - m
print(ans)

Submission status: Accepted

Solution code:
# Nは十分大きく偶数
N = int(input())
nums = list(map(int, input().split()))

# ソートして半分の位置にあるP, Qの値を見つけて、Q-Pすればいい
sorted_nums = sorted(nums)

# たとえば6個なら範囲が0-5なので2,3がPQになる
Q = int(N / 2)
P = Q - 1

print(sorted_nums[Q] - sorted_nums[P])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import stdin

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

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

input = lambda: stdin.readline()
main()

Submission status: Accepted

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

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

Submission status: Accepted

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

ha = n//2 - 1
dn.sort()
if dn[ha] == dn[ha+1]:
  print(0)
else:
  print(dn[ha+1]-dn[ha])

Submission status: Accepted

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

Submission status: Accepted

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

A.sort()
s=0

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

Submission status: Accepted

Solution code:
import sys

def input():
    return sys.stdin.readline().rstrip()

if __name__ == "__main__":
    n = int(input())
    dl = list(map(int, input().split()))

    dl.sort()
    midindex = n // 2

    print(dl[midindex] - dl[midindex-1])

Submission status: Accepted

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

sorted_d = sorted(d)

a = sorted_d[int(n/2)]
b = sorted_d[int(n/2) - 1]

print(a-b)

Submission status: Accepted

Solution code:
import sys

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
import numpy as np
sys.setrecursionlimit(1000000)
 
n = int(input())
d = list(map(int,input().split()))

d.sort()

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

Submission status: Accepted

Solution code:
from sys import stdin

N=int(stdin.readline().rstrip())
if N % 2 == 1:
    output=0
else:
    num_list=[int(x) for x in stdin.readline().rstrip().split()]
    num_list.sort()
    output=0
    half=int(N/2)
    output=num_list[half]-num_list[half-1]

print(output)

Submission status: Accepted

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

Submission status: Accepted

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

def delete(larger, move):
    for i in move:
        larger.remove(i)
    return larger

def solve(N: int, d: "List[int]"):
    ABC = []
    ARC = sorted(d)

    count = 0

    for K in range(10**6):
        move = []
        for i in ARC:
            if i < K:
                move.append(i)
            else:
                break
        ABC += move
        delete(ARC, move)

        if len(ABC) == len(ARC):
            count += 1
        elif len(ABC) > len(ARC):
            break
        
    print(count)

    return


# Generated by 1.1.4 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:
#C
n = int(input())
d = list(map(int,input().split()))
d.sort()
sub = d[n//2] - d[n//2 - 1]
print(sub)

Submission status: Accepted

Solution code:
from sys import stdin
N = int(stdin.readline().rstrip())
input = stdin.readline().split()
d = [int(input[i]) for i in range(N)]
d_sorted = sorted(d)
# print(d)
# print(d_sorted)
# print(d_sorted[int(N/2)])
# print(d_sorted[int(N/2)-1])
print(d_sorted[int(N/2)] - d_sorted[int(N/2)-1])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

def solve(n, d):
    d = sorted(d)
    return d[n/2] - d[n/2 - 1]


if __name__ == '__main__':

    n = sys.stdin.readline().strip()
    d = map(int, sys.stdin.readline().strip().split(" "))
    print solve(int(n), d)

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

half = int(n/2)

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

Submission status: Accepted

Solution code:
# C問題
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  n=I()
  l=LI()

  l.sort()

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

  return b-a

print(main())

Submission status: Accepted

Solution code:
su=int(input())
num=list(map(int,input().split()))
ar=num.sort()
half=int(su/2)
print(num[half]-num[half-1])

Submission status: Accepted

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

abc = 0
arc = N

ans = 0
for k in range(1, 10 ** 5 + 1):
    while True:
        if abc >= N:
            break
        elif d[abc] < k:
            abc += 1
            arc -= 1
        else:
            break
    if abc == arc:
        ans += 1
    elif abc > arc:
        break

print(ans)

Submission status: Accepted

Solution code:
N = int(input())
ds = [int(p) for p in input().split(" ")]
k = 0
ds.sort()
ma = ds[N//2-1]
mi = ds[N//2]
print(mi - ma)

Submission status: Accepted

Solution code:
n = int(input())
lst = [int(i) for i in input().split()]
lst = sorted(lst)
cnt = 0
d = int(n/2-1)
l = lst[d]
u = lst[d+1]
   
if l==u:
    cnt = 0
else:
    cnt = u-l
print(cnt)

Submission status: Accepted

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

sorted = sorted(d)

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

Submission status: Accepted

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

d.sort()

small=d[(N//2)-1]
large=d[N//2]

ans=large-small

print(ans)

Submission status: Accepted

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

p.sort()

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

Submission status: Accepted

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

Submission status: Accepted

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

def ans() :
	l = len(d)
	if l % 2 == 1 : return 0
	d.sort()
	l = int(l/2)
	if d[l-1] == d[l] : return 0
	return d[l] - d[l-1]

print(ans())

Submission status: Accepted

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

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

Submission status: Accepted

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

print(nk)

Submission status: Accepted

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

D = sorted(d)
x = int(N/2)


A = D[x-1]
B = D[x]

print(B-A)

Submission status: Accepted

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

d.sort()

c=0

if d[N//2-1]!=d[N//2]:
    c=d[N//2]-d[N//2-1]

print(c)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())

lst = list(map(int, input().split()))
s_lst = sorted(lst)

f = n//2 
b = n//2 - 1
print(s_lst[f] - s_lst[b])

Submission status: Accepted

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

dd = sorted(d)
ans = 0

if dd[int(n/2)] != dd[int(n/2)-1]:
    ans += dd[int(n/2)]-dd[int(n/2)-1]

print(ans)

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import bisect
n = int(input())
d = sorted(map(int, input().split()))
m1 = d[n // 2 - 1]
m2 = d[n // 2]
r = d[bisect.bisect_left(d, m2)]
l = d[bisect.bisect_left(d, m1)]
print(r - l)

Submission status: Accepted

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

center = N // 2

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = int(input())
d = list(map(int, input().split(' ')))
d = sorted(d)
mid = n//2-1
if d[mid] == d[mid+1]:
  ans = 0
else:
  start = d[mid] +1
  end = d[mid+1] 
  ans = end - start + 1
print(ans)

Submission status: Accepted

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

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