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

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

D = sorted(d)

cn = 0
for i in range(10**5):
    if i > D[N//2 - 1] and i <= D[N//2]:
        cn = cn + 1

    
print(cn)

Submission status: Wrong Answer

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

D = sorted(d)

cn = 0
for i in range(10**5):
    if i >= D[N//2 - 1] and i <= D[N//2]:
        cn = cn + 1

    
print(cn - 1)

Submission status: Wrong Answer

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

D = sorted(d)
print(D)
cn = 0
for i in range(10**5):
    if i >= D[N//2 - 1] and i <= D[N//2]:
        cn = cn + 1

    
print(cn - 1)

Submission status: Wrong Answer

Solution code:
n = int(input());
arr = list(map(int, input().split()));
arr.sort();
ans = 0;
for i, x in enumerate(arr):
  arc_arr = list(filter(lambda target: target >= x, arr));
  if len(arc_arr) == n - len(arc_arr): ans = x - arr[i-1]
print(ans);

Submission status: Wrong Answer

Solution code:
n = int(input());
arr = list(map(int, input().split()));
count = 0;
for x in range(0, max(arr)):
  arc_arr = list(filter(lambda target: target >= x, arr));
  if len(arc_arr) == n - len(arc_arr): count += 1;
print(count);

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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-1)[ansstd > 1])

Submission status: Wrong Answer

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

q = sorted(p)

cor = q[int(N/2)] - q[int(N/2 - 1)]



if cor == 0:
 print(0)
else:
 print(cor + 1)

Submission status: Wrong Answer

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 <= 1:
    print(0)
else:
    print(diff)

Submission status: Wrong Answer

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

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

for i in range(n):
    for j in range(i):
        if d[j] > d[j+1]:
            tmp = d[j]
            d[j] = d[j+1]
            d[j+1] = tmp

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

Submission status: Wrong Answer

Solution code:
N = int(input())
D = list(map(int, input().split()))
SD = sorted(D)
m = len(D) // 2
med = (SD[m - 1] + SD[m]) // 2
l, h = 0, 0
for d in SD:
	if d < med:
		l = d
	elif h == 0:
		l = min(med, l + 1)
		h = d
		break
if h != l:
	print(h - l + 1)
else:
	print(0)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys, math, itertools, collections, bisect 
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8') 
inf = float('inf') ;mod = 10**9+7 
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n=int(input())
A=[(e,i) for i,e in enumerate(list(map(int,input().split())))]
print(A)
A.sort(key=lambda tup: tup[0])
print(A)
for e,i in A:
    print(e, i+1)

Submission status: Wrong Answer

Solution code:
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8') 
inf = float('inf') ;mod = 10**9+7 
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n = int(input())
D = list(map(int, input().split()))
D.sort()
for k in range(min(D),max(D)):
    arc = 0
    abc = 0
    for i in range(n):
        if D[i] >= k:
            arc += 1
        else:
            abc += 1
    if arc == abc:
        count += 1
print(count)

Submission status: Wrong Answer

Solution code:
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8') 
inf = float('inf') ;mod = 10**9+7 
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n = int(input())
D = list(map(int, input().split()))
D.sort()
for k in range(max(D)):
    arc = 0
    abc = 0
    for i in range(n):
        if D[i] >= k:
            arc += 1
        else:
            abc += 1
    if arc == abc:
        count += 1
print(count)

Submission status: Wrong Answer

Solution code:
N = int(input())
li = list(map(int, input().split()))
li.sort()
a = li[N//2]
flag = True
print(li)
for i in range (N//2):
    if a == li[i]:
        flag = False
if flag:
     print(li[N//2]-li[N//2-1])
else:
     print(0)

Submission status: Wrong Answer

Solution code:
N = int(input())
li = list(map(int, input().split()))
li.sort()
a = li[N//2]
flag = True
for i in range (N):
    if i != N//2 and a == li[i]:
        flag = False
if flag:
     print(li[N//2]-li[N//2-1])
else:
     print(0)

Submission status: Wrong Answer

Solution code:
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8') 
inf = float('inf') ;mod = 10**9+7 
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n = int(input())
D = list(map(int, input().split()))
for k in range(1, max(D)):
    left = 0
    right = 0
    for i in range(n):
        if D[i] < k:
            left += 1
        else:
            right += 1
    if left == right:
        ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=sorted(list(map(int, input().split())))
l=min(a);h=max(a)
res=0
for i in range(l+1,h):
    ans=0
    for j in a:
        ans+=j>=i
    if ans == n//2:res+=1
print(res)

Submission status: Wrong Answer

Solution code:
#入力:[n1,n2,...nk](int:整数配列)
def input_array():
	return list(map(int,input().split()))
  
n=int(input())
d=input_array()
d.sort()
MAX=d[-1]

count=0
for k in range(MAX):
	down=0 #Kより下
	up=0
	for j in d:
		if j < k:
			down+=1
		else:
			up+=1
	if down==up:
		count+=1
print(count)

Submission status: Wrong Answer

Solution code:
import numpy as np
n = int(input())
ds = list(map(int, input().split()))
ds = np.array(ds)
ans = 0
for i in range(1, max(ds)):
    temp1 = np.count_nonzero(ds < i)
    temp2 = np.count_nonzero(ds >= i)
    if temp1 == temp2:
        ans += 1

print(ans)

Submission status: Wrong Answer

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

d=sorted(d)
ans=0

for i in range(10**5):
    if d[int(N/2-1)] < i and i <= d[int(N/2)]:
        ans +=1

print(ans)

Submission status: Wrong Answer

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

half1=di[(n-1)//2]
half2=di[(n-1)//2+1]
ans=half2-half1
if ans>1:
    print(ans)
else:
    print(0)

Submission status: Wrong Answer

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

d=sorted(d)
ans=0

if N%2==0:
    for i in range(10**5):
        if d[int(N/2-1)] < i and i <= d[int(N/2)]:
            ans +=1
else:
    for i in range(10**5):
        if d[int(N//2+1)] == i:
            ans +=1
print(ans)

Submission status: Wrong Answer

Solution code:
n=int(input())
d=list(map(int,input().split()))
ans=0
for k in range(max(d)):
    dn=0
    for i in d:
        if i<k:
            dn+=1
        else:
            pass
    if dn==len(d)/2:
        ans+=1
print(ans)

Submission status: Wrong Answer

Solution code:
N=int(input())
d=[int(x) for x in input().split()]
d.sort()
high=max(d)
low=0
while((high-low)>=2):
  if len([x for x in d if x<int((high+low)/2)])<N/2:
    low=int((high+low)/2)
  elif len([x for x in d if x<int((high+low)/2)])>N/2:
    high=int((high+low)/2)
  else:
    break
M=int((high+low)/2)
count=1
print(M)
if len([x for x in d if x<M])!=N/2:
  print(0)
else:
  while len([x for x in d if x<M])==N/2:
    count=count+1
    M=M+1
  print(count)
  print(M)
  print(len([x for x in d if x<M-1])==N/2)

Submission status: Wrong Answer

Solution code:
import sys

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

if N % 2 != 0:
    print(0)
    sys.exit()

low  = D[0:N//2]
high = D[N//2::]

cnt = 0
flg = True
for i in range(low[-1] - 1, min(high) + 1):
    flg = False
    flg  = all( i >  x for x in low )
    flg |= all( i >= x for x in high )

    if flg == True:
        cnt = cnt + 1

print(cnt)

Submission status: Wrong Answer

Solution code:
import sys

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

if N % 2 != 0:
    print(0)
    sys.exit()

low  = D[0:N//2]
high = D[N//2::]

cnt = 0
flg = True
for i in range(low[-1], max(D)):
    flg = True
    for L in low:
        if i <= L:
            flg = False
    for L in high:
        if i > L:
            flg = False

    if flg == True:
        cnt = cnt + 1
print(cnt)

Submission status: Wrong Answer

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

ans = 0
for j in range(len(p)):
    agc = [i for i in p if i>j]
    if len(agc) == len(p)-len(agc):
        ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
def count_up(d, cut):
    ABC = len([1 for i in d if i < cut])
    ARC = len(d) - ABC
    if ABC == ARC:
        return True
    return False

N = int(input())
d = list(map(int, input().split()))
counter = 0
for i in range(max(d)):
    if count_up(d, i):
        counter += 1
print(counter)

Submission status: Wrong Answer

Solution code:
def count_up(d, cut):
    ABC = len([1 for i in d if i < cut])
    ARC = len(d) - ABC
    if ABC == ARC:
        return True
    return False

N = int(input())
d = list(map(int, input().split()))
avg = sum(d) // len(d)
counter = 0
if count_up(d, avg):
    counter += 1
    _avg = avg - 1
    while count_up(d, _avg):
        counter += 1
        _avg -= 1
    _avg = avg + 1
    while count_up(d, _avg):
        counter += 1
        _avg += 1
print(counter)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

D.sort()

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

Submission status: Wrong Answer

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

ans = 0
for i in range(min(D)+1, max(D)):
    RC = [r for r in D if r >= i]
    BC = [b for b in D if b < i]
    if len(RC) == len(BC):
        ans += 1

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

d.sort()
mind = d[n//2-1]
maxd = d[n//2]

print(mind,maxd)

ans = maxd - (mind + 1) + 1
if ans < 0:
    print(0)
    exit()
print(ans)

Submission status: Wrong Answer

Solution code:
# ans

import sys
input = sys.stdin.readline
N = int(input())
d = list(map(int, input().split()))
d.sort()

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

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
N = int(input())
d = list(map(int, input().split()))
d.sort()
K = 0

for i in range(N):
  if d[i] < N / 2:
    K += 1
    
print(K)

Submission status: Wrong Answer

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


left = d[tar]
right = d[tar + 1]
print(left, right)
diff = right - left
if (diff == 0):
    ans = 0
else:
    ans = diff

print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
points = list(map(int, input().split()))
ans = 0

for k in range(int(sum(points)/2)):
    arc_list = []
    abc_list = []
    for point in points:
        if point >= k:
            arc_list.append(point)
        else:
            abc_list.append(point)
    if len(arc_list) == len(abc_list):
        ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
d = sorted(list(map(int,input().split())))
a = sum(d)//len(d)
ans = 0
flagp = False
flagm = False
for i in range(max(d)):
#    print (a+i,a-i)
    if i == 0:
        abc = [x for x in d if x < a]
        arc = [x for x in d if a <= x]
#        print (abc,arc)
        if len(abc) == len(arc):
            ans += 1
        else:
            break
    else:
        abcp = [x for x in d if x < a+i]
        arcp = [x for x in d if a+i <= x]
        if len(abcp) == len(arcp):
            ans += 1
        else:
            flagp = True

        abcm = [x for x in d if x < a-i]
        arcm = [x for x in d if a-i <= x]
        if len(abcm) == len(arcm):
            ans += 1
        else:
            flagm = True

#        print (abcp,arcp)
#        print (abcm,arcm)
        if flagp and flagm:
            break

print (ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
d = sorted(list(map(int,input().split())))
a = sum(d)//len(d)
ans = 0
for i in range(max(d)):
    if i == 0:
        abc = [x for x in d if x < a]
        arc = [x for x in d if a <= x]
        if len(abc) == len(arc):
            ans += 1
    else:
        abcp = [x for x in d if x < a+i]
        arcp = [x for x in d if a+i <= x]
        if len(abcp) == len(arcp):
            ans += 1

        abcm = [x for x in d if x < a-i]
        arcm = [x for x in d if a-i <= x]
        if len(abcm) == len(arcm):
            ans += 1

        if len(abcp) != len(arcp) and len(abcm) != len(arcm):
            break

print (ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

arc_list = list()
abc_list = list()

harf_num = int(n/2)

d.sort()
abc_list = d[:harf_num]
arc_list = d[harf_num:]

abc_max = max(abc_list)
arc_min = min(arc_list)

print(abc_max - arc_min)

Submission status: Wrong Answer

Solution code:
n = int(input())
d = sorted(list(map(int, input().split())))
h = int(len(d) / 2)
ans = 0

if d[h-1] != d[h]:
    if d[h-2] != d[h-1] or d[h] != d[h+1]:
        ans = d[h] - d[h-1]

print(ans)

Submission status: Wrong Answer

Solution code:
import bisect
N=int(input())
d=list(map(int,input().split()))
d=sorted(d)
num=len(d)
ans=0
for i in range(N+1):
  tmp=bisect.bisect_left(d,i)
  if tmp==num-tmp:
    ans+=1
print(ans)

Submission status: Wrong Answer

Solution code:
# For taking integer inputs.
def inp():
    return(int(input()))


# For taking List inputs.
def inlist():
    return(list(map(int, input().split())))


# For taking string inputs. Actually it returns a List of Characters, instead of a string, which is easier to use in Python, because in Python, Strings are Immutable.
def instr():
    s = input()
    return(list(s[:len(s)]))


# For taking space seperated integer variable inputs.
def invr():
    return(map(int, input().split()))


n = inp()

arr = inlist()
arr = sorted(arr)
n = int(n/2)
kl = int(arr[n-1])
kh = int(arr[n])
print(arr)
print(kl, kh)
print(max(0, kh-kl))

Submission status: Wrong Answer

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

# check
max_diff = max(d)
min_diff = min(d)
cnt = 0
for k in range(min_diff, max_diff):
    if len([i for i in d if i >= k]) == len([j for j in d if j < k]):
        cnt += 1

print(cnt)

Submission status: Wrong Answer

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

# check
sort_d = sorted(d)
c = N // 2
print(len(list(range(sort_d[c - 1] + 1, sort_d[c]))))

Submission status: Wrong Answer

Solution code:
n = int(input())
d = list(map(int,input().split()))
c = 0
k = 0
while True:
  if(k == max(d)):
    break
  ab = 0
  ar = 0
  for i in range(0,n):
    if(d[i] >= k):
      ar = ar + 1
    else:
      ab = ab + 1
  if(ab == ar):
    c = c + 1
  k = k + 1
print(c)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
a.sort()
ans = []

nh1 = n//2 - 1
nh2 = nh1 + 1

if a[nh1] == a[nh2]:
    print(0)
else:
    for i in range(a[nh1]+1,a[nh2]+1):
        ans.append(i)

print(len(ans))

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
a.sort()
ans = []

nh1 = n//2 - 1
nh2 = nh1 + 1

if a[nh1] == a[nh2]:
    print(0)
else:
    for i in range(a[nh1],a[nh2]):
        ans.append(i)

print(len(ans))

Submission status: Wrong Answer

Solution code:
n = int(input())
d = list(map(int,input().split()))
cnt=0
for i in range(1,len(d)+1):
    arc = 0
    abc = 0
    for j in d:
        if j >= i:
            arc+=1
        else:
            abc+=1
    if arc==abc:
        cnt+=1
print(cnt)

Submission status: Wrong Answer

Solution code:
N = int(input().rstrip())
line = input().rstrip()
l = [int(v) for v in line.split()]
l.sort()
uniq_list = sorted(list(set(l)))
result = 0
cur_i = 0
for i in range(len(uniq_list)):
    for j in range(cur_i, len(l)):
        if uniq_list[i] == l[j]:
            if (N / 2) == j:
                result = uniq_list[i] - uniq_list[i - 1]
                break
            else:
                cur_i = j + 1

print(result)

Submission status: Wrong Answer

Solution code:
import sys

input = sys.stdin.readline

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

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

print(d)

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

Submission status: Wrong Answer

Solution code:

import sys
read = sys.stdin.buffer.read # 全読み込み
readline = sys.stdin.buffer.readline # 一行読み込み
readlines = sys.stdin.buffer.readlines # 一行ずつ全読み込み
sys.setrecursionlimit(10**7) # 再帰限界変更（デフォルトは1000）

"""
# 文字列（数値変換も含む）
n = readline().rstrip() # １行に１文字列のみ
lis = readline().rstrip().split() # # １行に複数の文字列

# 数値（文字変換も含む）
n = int(readline().rstrip()) # １行に数値１個のみ
a, b, c = map(int,readline().rstrip().split()) # １行に複数の数値
A = list(map(int,readline().rstrip().split()))  # １行に複数の数値（リスト受け取り）
lis = [readline().rstrip().split() for _ in range(n)] # 

"""

n=int(readline().rstrip())
d=list(map(int,readline().rstrip().split()))

cnt=0
cnt_k=0
d_inv=sorted(d)
num=len(d_inv)

for i in range(d_inv[-1]):
    if len([int(j) for j in d if j<i])==num/2:
        cnt_k+=1

print(cnt_k)

Submission status: Wrong Answer

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

dictio ={}

for i in range(N):
    if d[i] in dictio:
        temp = dictio[d[i]]
        dictio[d[i]] = temp+1
    else:
        dictio[d[i]]  = 1

cnt = 0
left =0
right =0
flg =False

for key,value in dictio.items():
    cnt += value
    if cnt == (N/2) and  flg == False:
        left = key
        flg = True
    elif flg == True:
        right = key
        break
        
        
        
print(right-left)

Submission status: Wrong Answer

Solution code:
N = int(input())
p = [int(s) for s in input().split()]
sum([ sorted([p1,p2,p3])[1] == p2 for p1,p2,p3 in zip(p[2:],p[1:(N-1)],p[:(N-2)])])

Submission status: Wrong Answer

Solution code:
N = int(input())
p = [int(s) for s in input().split()]
print(sum([ sorted([p1,p2,p3])[1] == p1 for p1,p2,p3 in zip(p[2:],p[1:(N-1)],p[:(N-2)])]))

Submission status: Wrong Answer

Solution code:
N = int(input())
p = [int(s) for s in input().split()]
sum([ sorted([p1,p2,p3])[1] == p1 for p1,p2,p3 in zip(p[2:],p[1:(N-1)],p[:(N-2)])])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
input=sys.stdin.readline
n=int(input())
L=list(map(int,input().split()))
L.sort()
num=abs(L[n//2-1]-L[n//2])
print(num if num!=1 else 0)

Submission status: Wrong Answer

Solution code:
import sys
input=sys.stdin.readline
n=int(input())
L=list(map(int,input().split()))
L.sort()
num=L[n//2]-L[n//2-1]
print(num if num!=1 else 0)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
d = list(map(int, input().split()))
d.sort()
S = sum(d)
if not d[N//2 - 1] <= S/N <= d[N//2]:
  print(0)
else:
  A = 0
  for i in range(d[N//2]-d[N//2 - 1]):
    if d[N//2 - 1] < d[N//2 - 1] + i+1 <= d[N//2]:
      A += 1  
  print(A)

Submission status: Wrong Answer

Solution code:
N = int(input())
d = list(map(int, input().split()))
d.sort()
S = sum(d)
if not d[N//2 - 1] < S/N <= d[N//2]:
  print(0)
else:
  A = 0
  for i in range(d[N//2]-d[N//2 - 1]):
    if d[N//2 - 1] < d[N//2 - 1] + i+1 <= d[N//2]:
      A += 1  
  print(A)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())

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

K = 1

ans = []
ARC = []
ABC = []
for j in range(1, max(d)):
    for i in range(N):
        if (d[i] >= K):
            ARC.append(d[i])
        else:
            ABC.append(d[i])
    if (len(ARC) == len(ABC)):
        ans.append(K)
    else:
        ARC = []
        ABC = []
    K += 1

print(len(ans))

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
for i in range(1,n+1):
    print(a.count(i))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N=int(input())
D=list(map(int,input().split()))
cnt=0
for i in range(1,N+1):
    c=[]
    for d in D:
        if d>=i:
            c.append(d)
    if len(c)==N//2:
        cnt+=1
print(cnt)

Submission status: Wrong Answer

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

same = N / 2

# d.sort()

# distribution = [0] * d[len(d) - 1]
# total = 0
# for di in d:
#     num = d.count(di)
#     distribution[di - 1] = num

table = {}
for di in d:
    table[di] = 1 if table.get(di) is None else table.get(di) + 1
table = sorted(table.items())

total = 0
for difficulty, num in table:
    total += num

# total = 0
# totals = [0] * d[len(d) - 1]
# num = 0
# for i in range(len(distribution)):
#     total += distribution[i]
#     totals[i] = total

#     if totals[i] == same:
#         num += 1
#     elif num >= 1:
#         break

print(1)

Submission status: Wrong Answer

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

same = N / 2

# d.sort()

# distribution = [0] * d[len(d) - 1]
# total = 0
# for di in d:
#     num = d.count(di)
#     distribution[di - 1] = num

table = {}
for di in d:
    table[di] = 1 if table.get(di) is None else table.get(di) + 1
print(table)
# total = 0
# totals = [0] * d[len(d) - 1]
# num = 0
# for i in range(len(distribution)):
#     total += distribution[i]
#     totals[i] = total

#     if totals[i] == same:
#         num += 1
#     elif num >= 1:
#         break

print(1)

Submission status: Wrong Answer

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

same = N / 2

d.sort()

distribution = [0] * d[len(d) - 1]
total = 0
for di in d:
    num = d.count(di)
    distribution[di - 1] = num

# total = 0
# totals = [0] * d[len(d) - 1]
# num = 0
# for i in range(len(distribution)):
#     total += distribution[i]
#     totals[i] = total

#     if totals[i] == same:
#         num += 1
#     elif num >= 1:
#         break

print(1)

Submission status: Wrong Answer

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

same = N / 2

d.sort()

distribution = [0] * d[len(d) - 1]
total = 0
for di in d:
    num = d.count(di)
    distribution[di - 1] = num

print(distribution)

total = 0
totals = [0] * d[len(d) - 1]
num = 0
for i in range(len(distribution)):
    total += distribution[i]
    totals[i] = total

    if totals[i] == same:
        num += 1
    elif num >= 1:
        break

print(num)

Submission status: Wrong Answer

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

abc = d_inputs[0:n//2]
arc = d_inputs[n//2:n]
print(abc,arc)
print(len([i for i in range(abc[-1]+1,arc[0]+1)]))

Submission status: Wrong Answer

Solution code:
import bisect
n = int(input())
li = list(map(int,input().split()))
li.sort()
#print(li)
count = 0
for i in range(1, max(li)):
    index = bisect.bisect_left(li, i)
    #print(n,index,n//2)
    if index == n//2:
        #print(index)
        count += 1
print(count)

Submission status: Wrong Answer

Solution code:
import bisect
n = int(input())
li = list(map(int,input().split()))
li.sort()
#print(li)
count = 0
for i in range(1, max(li)):
    index = bisect.bisect_left(li, i)
    #print(n,index,n//2)
    if index == (n+1)//2:
        #print(index)
        count += 1
print(count)

Submission status: Wrong Answer

Solution code:
import bisect
n = int(input())
li = list(map(int,input().split()))
li.sort()
#print(li)
count = 0
for i in range(1, max(li)):
    index = bisect.bisect_left(li, i)
    #print(n,index,n//2)
    if index == n//2:
        count += 1
print(count)

Submission status: Wrong Answer

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

d.sort()

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

d.sort()

if (N//2)%2==0:
    print(0)
else:
    K=d[(N//2)]-d[(N//2)-1]
    if d[N//2]!=d[(N//2)-2] and K==0:
        K=1
    elif d[N//2]==d[(N//2)-2]:
        K=0
    print(K)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

d.sort()

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

Submission status: Wrong Answer

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

d.sort()

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

Submission status: Wrong Answer

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

d.sort()

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

Submission status: Wrong Answer

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

d.sort()

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

d.sort
i = int(len(d)/2)

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

Submission status: Wrong Answer

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

d.sort
i = int(len(d)/2)

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

Submission status: Wrong Answer

Solution code:
n = int(input())
d = [int(i) for i in input().split()]
d.sort()
c = 0
y = d[len(d)//2-2:len(d)//2+2]


for k in range(min(y), max(y)):

	arc = []
	abc = []

	for j in d:
		if k <= j:
			arc.append(j)
		else:
			abc.append(j)
			
	if len(arc) == len(abc):
		c+=1 

print(c)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:

N = int(input())

data = list(map(int, sorted(input().split())))
median = int(N / 2)
#print(data)
print(data[median] - data[median - 1])

Submission status: Wrong Answer

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

d.sort()
ans = []
if d[n//2 -1] == d[n//2]:
    print("0")
else:
    for i in range(d[n//2 -1] + 1,d[n//2] + 1):
        ans.append(i)

        
print(len(ans))

Submission status: Wrong Answer

Solution code:
import sys

n, *d = map(int, sys.stdin.read().split())

def main():
    d.sort()
    h = n // 2
    l = d[h-1]; r = d[h]
    return r - (l + 1) - 1

if __name__ == '__main__':
    ans = main()
    print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# ALC 005 C

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

list_d.sort()
list_d[N//2] - list_d[N//2 -1]