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()))

dmax = max(d)
dmin = min(d)

count3 = 0

for i in range(dmin,dmax):
    count1 = 0
    count2 = 0
    for j in range(N):
        if d[j] >= i:
            count1 += 1
        else:
            count2 += 1

    if count1 == N/2 == count2 == N/2:
        count3 += 1

print(count3)

Submission status: Wrong Answer

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

dmax = max(d)
dmin = min(d)

count3 = 0

for i in range(0,dmax):
    count1 = 0
    count2 = 0
    for j in range(N):
        if d[j] >= i:
            count1 += 1
        else:
            count2 += 1

    if count1 == N/2 == count2 == N/2:
        count3 += 1

print(count3)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
def main():
    N = int(input())
    D =[int(i) for i in input().split()]
    count = 0
    D.sort()
    D.reverse()
    #print(D)
    for j in range(10000):
        for i in range(N):
            if D[i] < j:
                if i == (N/2):
                    count+=1
                else:
                    break
    print(count)
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

kmax=max(li)
count=0
for k in range(kmax):
  miman=0
  ijou=0
  for num in li:
    if num >= k:
      ijou+=1
    elif num < k:
      miman+=1
      
  if ijou==miman:
    count+=1
print(count)

Submission status: Wrong Answer

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

L=0
R=0
DDT = 0
ans = 0
for K in range(min(d),max(d)+1):
    for i in range(N):
        if d[i] == K:
            DDT += 1
        elif d[i] < K:
            L += 1
        else:
            R += 1
    print(L,R)
    if L == R:
        ans += 1
    else:
        while DDT > 0:
            if L < R:
                L += 1
                DDT -= 1
            elif L > R:
                R += 1
                DDT -= 1
            else:
                L += 1
                DDT -= 1
        if L == R:
            ans += 1
    L = 0
    R = 0
    DDT = 0
print(ans-1)

Submission status: Wrong Answer

Solution code:
N = int(input())
D = list(map(int, input().split()))
ans = 0
for i in range(max(D)) :
  cnt = len(list(filter(lambda x : x <= i, D)))
  if(cnt == N // 2) :
    ans += 1
    print(i)
  else :
    pass
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
d = [int(e) for e in input().split()]
d.sort()
sum = 0
if d[n//2] == d[n//2-1]:
    print(0)
else:
    for i in range(d[n//2]-d[n//2-1]):
        #print(d[n//2-1]+i+1)
        sum+=1

print(sum)

Submission status: Wrong Answer

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

print (D)
D.sort()
print (D)
print (D[:N/2])

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

Submission status: Wrong Answer

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

s=0
N=int(n/2)
k=abs(d[N]-d[N-1])
K=int((d[N]+d[N-1])/2)
for i in range(n):
    if d[i]>=K:
        s=s+1
    else:
        s=s

if s==N:
    print(k)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
N = int(input())
d = list(map(int, input().split()))
d.sort()
res = 0
harf_N = int(N/2)
for k in range(d[N - 1]):
  if((d[harf_N - 1] < k) and (d[harf_N] >= k)):
    res += 1
print(res)

Submission status: Wrong Answer

Solution code:
n = int(input())
d_list = [int(i) for i in input().rstrip().split(' ')]
d_list.sort()
print(d_list)

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

if d_list[a] == d_list[b]:
  print(0)
else:
  print(d_list[b] - d_list[a])

Submission status: Wrong Answer

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

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

ans = 0

D.sort()

for k in range(1,D[N-1]):
    for i in range(N):
        if D[i] < k and k <= D[i+1]:
            if i+1 == N//2:
                ans = ans + 1

print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

d.sort()
print(d)

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

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

if d[b] - d[a] == 2:
  print("2")
elif d[b] - d[a] == 1:
  print("1")
else:
  print("0")

Submission status: Wrong Answer

Solution code:
K=int(input())
D=[int(x) for x in input().split()]
D.sort()
M=K/2
m=M-1
ans=D[int(M)]-D[int(m)]
if ans==0:
  ans=1
print(ans)

Submission status: Wrong Answer

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

d.sort()

s = 0
if N % 2 == 0:
    center = d[int(N / 2)]
    center_ = d[int(N / 2) - 1]
    if center == center_:
        if d.count(center) % 2 == 0:
            print(0)
    else:
        print(center - center_)
else:
    print(0)

Submission status: Wrong Answer

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

k = 2
num = 0
ARC,ABC = [],[]
while k < max(s):
    for i in range(n):
        if s[i] >= k:
            ARC.append(s[i])
        elif s[i] < k:
            ABC.append(s[i])

    if len(ARC) == len(ABC):
        num+=1
    ARC,ABC = [],[]

    k+=1
print(num)

Submission status: Wrong Answer

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

d.sort()

s = 0
if N % 2 == 0:
    center = d[int(N / 2)]
    center_ = d[int(N / 2) - 1]
    print(center, center_)
    if center == center_:
        if d.count(center) % 2 == 0:
            print(0)
    else:
        print(center - center_)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
N = int(input())
input_line = [input() for i in range(1)]
d = list(map(int,input_line[0].split()))
K = []

for k in range(max(d)):
    ARC = []
    ABC = []    
    for i in range(N):
        if d[i] >= k:
            ARC.append(d[i])
        if d[i] < k:
            ABC.append(d[i])
    if len(ARC) == len(ABC):
        K.append(k)
print(len(K))

Submission status: Wrong Answer

Solution code:
"""
N個の問題が存在する(N%2==0)
その問題には難易度(d)が設定されていて、i番目の問題の難易度はd[i]である

設定された難易度のしきい値より大きいか小さいかよって2つのグループに分けたい
2つのグループに分けたときに、問題数が等しくなるような難易度のしきい値はいくつ存在するか
"""

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

ans = 0
max_n = d[-1]
half = N // 2



for k in range(1, max_n):
    cnt = 0
    for i in d:
        if i >= k:
            cnt += 1

    if cnt == half:
        ans += 1

print(ans)

Submission status: Wrong Answer

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

minn = min(p)
maxn = max(p)

print(minn)

Submission status: Wrong Answer

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

mid1 = d[n//2-1]
mid2 = d[n//2]

mid_num = mid2 - mid1 - 1
res = mid_num
mid1c = d.count(mid1)
mid2c = d.count(mid2)

if mid1c <= 2:
    res += 1
elif mid1c > 2:
    res -= 1

if mid2c == 2:
    res += 1
elif mid2c > 2:
    res -= 1

if mid1 == mid2:
    res = 0
print(max(0, res))

Submission status: Wrong Answer

Solution code:
n = int(input())
ls = list(map(int,input().split(" ")))
max = max(ls)
ans = 0

for i in range(max):
  n = sum(x >= i for x in ls)
  m = sum(x < i for x in ls)
  if n == m:
    ans += 1

print(ans)

Submission status: Wrong Answer

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

d.sort()
avg = mean(d) // 1

d1 = [i for i in d if i <= avg]
d2 = [i for i in d if i > avg]

if len(d1) == len(d2):
    a = d2[0] - d1[-1]
    print(a)
    sys.exit()
print(0)

Submission status: Wrong Answer

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

cnt=0
cnth=0
cntl=0
for k in range(min(d)+1, max(d)-1):
    for x in d:
        if x >= k:
            cnth += 1
        elif x < k:
            cntl += 1
    if cnth == cntl:
        cnt+=1
    cnth =0
    cntl =0

print(cnt)

Submission status: Wrong Answer

Solution code:
import statistics
n = int(input())
d = input().split(' ')
d = [int(i) for i in d]
m = int(statistics.median(d))
if m in d:
  print(0)
else:
  nn = int(n/2) 
  d.sort()
  print(d[nn] - d[nn-1])

Submission status: Wrong Answer

Solution code:

from statistics import mean
N = int(input())
d = list(map(int,input().split()))

d.sort()
avg = mean(d) // 1

d1 = [i for i in d if i <= avg]
d2 = [i for i in d if i > avg]

if len(d1) == len(d2):
    a = d2[0] - d1[-1]
    print(a)
print(0)

Submission status: Wrong Answer

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

cnt=0
cnth=0
cntl=0
for k in range(min(d)+1, max(d)-1):
    for x in d:
        if x >= k:
            cnth += 1
        elif x < k:
            cntl += 1
    if cnth == cntl:
        cnt+=1
    cnth =0
    cntl =0

print(cnt)

Submission status: Wrong Answer

Solution code:
n = int(input())
p = set(map(int, input().split()))
p = list(p)
p.sort()
if len(p) % 2 == 1 and n % 2 == 1:
    print(0)
else:
    p = list(p)
    cnt = p[len(p)//2] - p[len(p)//2 -1]
    print(cnt)

Submission status: Wrong Answer

Solution code:
N = int(input())
if N % 2 == 1:
  print("0")
else:
  lis = input().split()
  
  if lis[int(N / 2 - 1)] == lis[int(N / 2)]:
    print("0")
  else:
    ans = []
    for i in range(int(lis[int(N / 2 - 1)]) + 1 , int(lis[int(N / 2)]) + 1): 
      ans.append(i)
    print(len(ans))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

d.sort()
avg = mean(d) // 1

d1 = [i for i in d if i <= avg]
d2 = [i for i in d if i > avg]

if len(d1) == len(d2):
    a = d2[0] - d1[-1]
    print(a)

Submission status: Wrong Answer

Solution code:
N=6
d=[9,1,4,4,6,7]
C=N//2
d.sort()
if d[C]==d[C-1]:
    print(0)
else:
    print(d[C]-d[C-1])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())

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

ans = 0

for i in range(1, n+1):
    abc = 0
    arc = 0
    for j in d:
        if j >= i:
            arc += 1
        elif j < i:
            abc += 1
    if arc == abc:
        ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:

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

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

Submission status: Wrong Answer

Solution code:
num = int(input())
seq = input().split()

sequence = [int(i) for i in seq]
count = 0
max_dif = max(sequence)

for i in range(max_dif):
  a, b = 0, 0
  for item in sequence:
    if item>=i: a+=1
    else: b+=1
  if a==b: count+=1

print(count)

Submission status: Wrong Answer

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

if len(p) % 2 == 1:
    print(0)
else:
    p = list(p)
    cnt = p[len(p)//2] - p[len(p)//2 -1]
    print(cnt)

Submission status: Wrong Answer

Solution code:
N=int(input())
d=list(map(int, input().split()))
C=N//2
for x in reversed(range(1,N+1)):
    for y in range(0,x-1):
        if d[y]<d[y+1]:
            t=d[y]
            d[y]=d[y+1]
if d[C]==d[C-1]:
    print(0)
else:
    print(d[C-1]-d[C])

Submission status: Wrong Answer

Solution code:
N=int(input())
d=list(map(int, input().split()))
C=N//2
for x in reversed(range(1,N+1)):
    for y in range(0,x-1):
        if d[y]<d[y+1]:
            t=d[y]
            d[y]=d[y+1]
            d[y+1]=t
print(d)
if d[C]==d[C-1]:
    print(0)
else:
    print(d[C-1]-d[C])

Submission status: Wrong Answer

Solution code:
import numpy as np

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

    d = np.array(sorted(d))
    count = 0
    for i in range(1, d[-1] - 1):
        first_half = d[d < i]
        second_half = d[d >= i]
        if first_half.size == second_half.size:
            count += 1

    print(count)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import statistics


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

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

    if med_high == med_low:
        answer = 0
    else:
        if d_list.count(med_high) == 1:
            answer = med_high - med_low
        else:
            answer = med_high - med_low - 1

    print(answer)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

print(n,d)

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans = 0

for k in range(min(l)+1, max(l)):
    l_abc = [i for i in l if i < k]
    l_arc = [i for i in l if i >= k]
    if len(l_abc) == len(l_arc):
        ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:

import statistics
import math
import numpy as np

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

v = np.zeros((np.max(d) + 1))
for i in range(n):
    v[d[i]] += 1

count = 0
m = int(statistics.median(d))

i = m -1
while v[i] <= 0:
    if np.sum(v[:i]) == np.sum(v[i:]):
        count += 1

    i -= 1

if np.sum(v[:i]) == np.sum(v[i:]):
    count += 1

i = m
while v[i] <= 0:
    if np.sum(v[:i]) == np.sum(v[i:]):
        count += 1

    i += 1

if np.sum(v[:i]) == np.sum(v[i:]):
    count += 1

print(count)

Submission status: Wrong Answer

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

else:
    pass
    
    
print(res)

Submission status: Wrong Answer

Solution code:
n=int(input())
p=list(map(int,input().split()))
o=0
ans=0
for k in range(min(p)+1,max(p)):
    for i in range(n):
        if k>p[i]:
            o+=1
    if o==len(p)/2:
        ans+=1
    o=0
print(ans)

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

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

if  __name__=='__main__':
    main()

Submission status: Wrong Answer

Solution code:
import bisect

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

d.sort()

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


print(ans)

Submission status: Wrong Answer

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

cnt = 0

d.sort()

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

Submission status: Wrong Answer

Solution code:
N = int(input())
D = list(map(int,input().split()))
ans = 0
for K in range(min(D),max(D)):
    ABC = 0
    for d in D:
        if d < K:
            ABC += 1
    if ABC == N-ABC:
        ans += 1
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

    smaller = []
    larger = d

    count = 0

    for i in range(10**5):
        move = []
        for k in larger:
            if k < i:
                move.append(k)
            else:
                break
        smaller += move
        delete(larger, move)

        if len(smaller) == len(larger):
            count += 1
        elif len(smaller) > len(larger):
            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: Wrong Answer

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

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

Submission status: Wrong Answer

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


N = int(input())
D = inpl()
D.sort()

if D[N // 2] == D[N // 2 - 1]:
    print(0)
    exit()

base = D[N // 2] - D[N // 2 - 1] - 1
if N == 2:
    print(base + 1)
    exit()

if D[N // 2] != D[N // 2 + 1]:
    base += 1

print(base)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def resolve():
    import numpy as np
    N = int(input())
    D = list(map(int, input().split()))
    d = np.array(D)

    ans = 0
    for i in range(min(d), max(d)):
        if len(d[d < i]) == len(d[d >= i]):
            ans += 1
    print(ans)

resolve()

Submission status: Wrong Answer

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

if d[l] == d[r]: print(0)
else:
    print(d[l],d[r])
    print(d[r]-d[l])

Submission status: Wrong Answer

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

count=0
for i in range(min(D),max(D)):
    count+=len([m for m in D if m>=i])==len([m for m in D if m<i])
print(count)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

print(num_list)
ans = 0

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    s = S()
    b = list(set(s))
    a = len(list(set(s)))
    if a == 2 and s.count(b[0]) == s.count(b[1]) == 2:
        print("Yes")
    else:
        print("No")
    return

#B
def B():
    n = II()
    p = LI()
    ans = 0
    for i in range(1,n-1):
        if (p[i - 1] < p[i] and p[i] < p[i + 1]) or (p[i + 1] < p[i] and p[i] < p[i - 1]):
            ans += 1
    print(ans)
    return

#C
def C():
    n = II()
    d = LI()
    d.sort()
    ans = 0
    for i in range(d[-1]):
        if n // 2 == bisect_left(d, i):
            ans += 1
    print(ans)
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    C()

Submission status: Time Limit Exceeded

Solution code:
#ABC132 C

N = int(input())
D = list(map(int,input().split()))
count = 0
for K in range(max(D) + 1):
    A = []
    B = []
    for i in range(N):
        if D[i] >= K:
            A.append(D[i])
        else:
            B.append(D[i])
        
    if len(A) == len(B):
        count += 1
        
    
    
print(count)

Submission status: Time Limit Exceeded

Solution code:
N  = int(input())
nums = list(map(int,input().split()))
nums.sort()
cnt = 0
for i in range(min(nums),max(nums)+1):
  if len(list(j for j in nums if j >= i)) == N //2 :
    cnt += 1
print(cnt)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
 
N = int(input())
d = np.array(list(map(int, input().split())))

ans = 0
for K in range(1, 10**5+1):
  if np.sum(d>=K) == np.sum(d<K): ans += 1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
# C
N = int(input())
D = sorted(list(map(int, input().split())))
center = len(D)//2
cnt = 0
for k in range(min(D), max(D)+1):
    for i in range(len(D)):
        if D[i] >= k:
            break
    if center == i:
        cnt += 1
print(cnt)

Submission status: Time Limit Exceeded

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

def quicksort(a):
  if len(set(a)) < 2:
    return a
  left = []
  center = a.pop(0)
  right = []
  for i in a:
    if center > i:
      left.append(i)
    else:
      right.append(i)
  left = quicksort(left)
  right = quicksort(right)
  left.append(center)
  left.extend(right)
  return left

D = quicksort(D)

left = D[int((N/2)-1)]
right = D[int(N/2)]
ans = 0
if left < right:
  ans = right - left
print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
l = list(map(int, input().split()))
for i in range(int(n/2-1)):
  l.remove(max(l))
  l.remove(min(l))
r = abs(l[1]-l[0])
print(r)

Submission status: Time Limit Exceeded

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

count = 0
for K in range(min(d),max(d)+1):
    ARC = [i for i in d if i >= K]
    ABC = [j for j in d if j < K]
    if len(ARC) == len(ABC):
        count += 1
print(count)

Submission status: Time Limit Exceeded

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

for i in range(1, d_max+1):
    abc = [x for x in d if x < i]
    if len(abc) == d_half:
        ans += 1

print(ans)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
d = list(map(int, input().split()))
min = min(d)
max = max(d)
count = 0
for k in range(min,max+1) :
    abc = 0 ; arc = 0
    for idx in range(n) :
        if d[idx] >= k :
            arc += 1
        else :
            abc += 1
    if abc == arc :
        count += 1
print(count)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
N=int(input())
d=[int(x) for x in input().split()]
d.sort()
M=max(d)
A=[]
for i in range(M+1):
  A.append(len([j for j in range(N) if d[j]==i]))
count=0
c=0
while(count<N/2):
  count=count+A[c]
  c=c+1
if count!=N/2:
  print(0)
elif count==N/2:
  d=0
  while(count==N/2):
    count=count+A[c]
    c=c+1
    d=d+1
  print(d)

Submission status: Time Limit Exceeded

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], min(high) + 1):
    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: Time Limit Exceeded

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

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

print(ans)

Submission status: Time Limit Exceeded

Solution code:
N = int(input())
d_array = list(map(int, input().split()))
#小さい順に並べ替え
for k in range(len(d_array)):
  for l in range(k):
    if d_array[l] > d_array[k]:
      d_array[k],  d_array[l] = d_array[l], d_array[k]

#真ん中の要素の差を取るとそれが答え
ans = d_array[N // 2] - d_array[N // 2 - 1]
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import itertools
import numpy as np

N = int(input())
points = np.array(list(map(int, input().split())))
ans = 0
s_points = sorted(points)

for k in range(max(points)+1):
    arc_list = points[points >= k]
    abc_list = points[points < k]
    if len(arc_list) == len(abc_list):
        ans += 1

print(ans)

Submission status: Time Limit Exceeded

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

for k in range(max(points)+1):
    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: Time Limit Exceeded

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

cnt = 0


for i in range(1,max(D)+1):
	arc = []
	abc = []
	for j in range(len(D)):
		if D[j] > i:
			arc.append(D[j])
		else:
			abc.append(D[j])
		#print(abc, arc)
	if len(arc) == len(abc):
		cnt += 1

print(cnt)

Submission status: Time Limit Exceeded

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

ans = 0
d.sort()

for k in range(n):
	abc = d[0:k]
	arc = d[k:n]
	if len(abc) == len(arc):
		ans = d[k] - d[k-1] 
print(ans)

Submission status: Time Limit Exceeded

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

for i in range(1,max(d)+1):
  ab = [j for j in d if i <= j]
  ar = [j for j in d if i > j]
  #print(ab,ar)
  if(len(ab)==len(ar)):
    c = c + 1
  ab = 0
  ar = 0
print(c)

Submission status: Time Limit Exceeded

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

ans=0
for i in range(1,d[-1]+1):
    cnt=0
    for j in range(n):
        if i>d[j]:
            cnt+=1
        else:
            break
    if n-cnt==cnt:
        ans+=1
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
n=int(input())
ds=list(map(int,input().split()))
sds=sorted(set(ds))
nds=np.array(ds)
ans=0
for i,d in enumerate(sds[1:]):
    l=sum(np.where(nds>=d,1,-1))
    if l==0:
        ans+=(d-sds[i])
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
n=int(input())
ds=list(map(int,input().split()))
nds=np.array(ds)
c=0
for k in range(min(ds),max(ds)+1):
    l=sum(np.where(nds<k,1,0))
    if l==n-l:
        c+=1
print(c)

Submission status: Time Limit Exceeded

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
for i in range(len(uniq_list)):
    j = l.index(uniq_list[i])
    if (N / 2) == j:
        result = uniq_list[i] - uniq_list[i - 1]
        break

print(result)

Submission status: Time Limit Exceeded

Solution code:
n = int(input())
p = list(map(int, input().split()))
ans = 0
for k in range(1, max(p) + 1):
    abc = 0
    arc = 0
    for i in p:
        if i < k:
            abc += 1
        else:
            arc += 1
    if abc == arc:
        ans += 1
print(ans)