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 = [int(i) for i in input().split()]
#  N = 6
#  d = list(sorted([9, 1, 4, 4, 6, 7]))
#  N = 8
#  d = sorted([9, 1, 14, 5, 5, 4, 4, 14])
#  N = 14
#  d = sorted(
#      [
#          99592,
#          10342,
#          29105,
#          78532,
#          83018,
#          11639,
#          92015,
#          77204,
#          30914,
#          21912,
#          34519,
#          80835,
#          100000,
#          1,
#      ]
#  )
l = len(d) // 2
boundary = d[l - 1]
next_d = boundary
boundary_cnt = 0
for i in d[l:]:
    if i == boundary:
        boundary_cnt += 1
        if boundary > 2:
            next_d = boundary
            break
    elif i > boundary:
        next_d = i
        break
print(next_d - boundary)

Submission status: Wrong Answer

Solution code:
N = int(input())
d = [int(i) for i in input().split()]
l = len(d) // 2
boundary = d[l - 1]
next_d = boundary
for i in d[l:]:
    if i > boundary:
        next_d = i
        break
print(next_d - boundary)

Submission status: Wrong Answer

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

d = sorted(d)

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

Submission status: Wrong Answer

Solution code:
N = int(raw_input())
d = map(int,raw_input().split())
ABC = []
ARC = []
ans = 0
for i in range(0,max(d)):
  for j in range(0,N):
    if d[j] >= i:
      ARC.append(d[j])
    else:
      ABC.append(d[j])
  if len(ABC) == len(ARC):
    ans = ans + 1
  ARC = []  
  ABC = []
print ans

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
N = int(input())
D = [int(i) for i in input().split(" ")]
count = 0
maxd = math.ceil(sum(D)/N)
for i in range(maxd+1):
    ARC = []
    ABC = []
    for j in D:
        if i < j:
            ARC.append(j)
        else:
            ABC.append(j)
    if len(ARC) == len(ABC):
        count+=1
print(count)

Submission status: Wrong Answer

Solution code:
N = int(input())
D = sorted([int(x) for x in input().split()])
l = D[len(D)//2-1]
h = D[len(D)//2]
if l == h:
  print(0)
else:
  print(h - l + 1)

Submission status: Wrong Answer

Solution code:
N = int(input())
D = sorted([int(x) for x in input().split()])
l = D[len(D)//2-1]
h = D[len(D)//2]
if l == h:
  print(0)
else:
  print(D.count(h) + h - l)

Submission status: Wrong Answer

Solution code:
N = int(input())
D = sorted([int(x) for x in input().split()])
l = D[len(D)//2-1]
h = D[len(D)//2]
if l == h:
  print(0)
else:
  print(D.count(h) + h - l - 1)

Submission status: Wrong Answer

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

import numpy as np
d=np.array(d)
Q=0
for i in range(max(d)):
    if np.count_nonzero(d<i)==N-np.count_nonzero(d<i):
        Q+=1
print(Q)

Submission status: Wrong Answer

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

k = d_list[int(N/2)]
print(k)

count = 0
for i in range(N):
    if count == int(N/2):
        print('k is ' + str(k)) 
        print(d_list[int(N/2)] - d_list[int(N/2)-1])
        break
    elif k > d_list[i]:
        count += 1
    else:
        pass
else: # kの候補の右端は必ずd_listの中
    print(0)

Submission status: Wrong Answer

Solution code:
N=int(input())
D=list(map(int,input().split()))
D.sort()
mi=D[0]
ma=D[N-1]
point=0
for j in range(mi+1,ma): #Kはj
    i=0
    while D[i]<j and i<N//2+1:
        i+=1
    if i==N//2 :
        point+=1
print(point)

Submission status: Wrong Answer

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

if d[int(n/2)]!=d[int((n/2)-1)]:
  for i in d:
    if i==d[int(n/2)]:
      gn+=1
  if gn==1:
    a+=1
  print(a)
else:
  print(0)

Submission status: Wrong Answer

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

if d[int(n/2)]!=d[int((n/2)-1)]:
  for i in d:
    if i==d[int(n/2)]:
      gn+=1
  if gn==1:
    a+=1
  print(a)
  print(d)
     
else:
  print(0)

Submission status: Wrong Answer

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

d.sort()
m = int(n / 2)
i = d[m-2] + 1

while i<= d[m-1]:
  count +=1
  i +=1
  
print(count)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

d.sort()
print(d)

d_len = len(d)

if d_len % 2 == 0:
    up = int(d_len/2)
    down = int(d_len/2) - 1
    if up == down:
        print('0')
    else:
        print(d[up]-d[down])
            
        

else:
    print('0')

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
kosuu=0
for k in range(min(a),max(a)):
    s=[]
    for j in range(n):
        if a[j]>=k:
            s.append(a[j])
    if len(s)==n//2:
        kosuu+=1
print(kosuu)

Submission status: Wrong Answer

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

a.sort()

c1 = a[len(a)//2]
c2 = a[len(a)//2-1]
if c1 != c2 and c1 != (c2 + 1):
    count = c1 - c2 -1
print(count)

Submission status: Wrong Answer

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

a.sort()

c1 = a[len(a)//2]
c2 = a[len(a)//2-1]
if c1 != c2 and c1 != (c2 + 1):
    count = a[len(a)//2] - a[len(a)//2-1]
print(count)

Submission status: Wrong Answer

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

a.sort()
if len(a) % 2 == 1:
  c = a[len(a)//2]
  if a.count(c) == 1:
    count = 1
else:
  c1 = a[len(a)//2]
  c2 = a[len(a)//2-1]
  if c1 != c2 and c1 != (c2 + 1):
    count = a[len(a)//2] - a[len(a)//2-1]
print(count)

Submission status: Wrong Answer

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

a.sort()
if len(a) % 2 == 1:
  c = a[len(a)//2]
  if a.count(c) == 1:
    count = (a[len(a)+1]-1)-a[len(a)-1]
else:
  c1 = a[len(a)//2]
  c2 = a[len(a)//2-1]
  if c1 != c2 and c1 != (c2 + 1):
    count = a[len(a)//2] - a[len(a)//2-1]
print(count)

Submission status: Wrong Answer

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

a.sort()
if len(a) % 2 == 1:
  c = a[len(a)//2]
  if a.count(c) == 1:
    count = (a[len(a)+1]-1)-a[len(a)-1]
else:
  c = a[len(a)//2]
  if a.count(c) == 1:
    count = a[len(a)//2] - a[len(a)//2-1]
print(count)

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

Solution code:
n=int(input())
s=list(map(int,input().split()))
print(s)
changed=sorted(s,reverse=True)

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

Submission status: Wrong Answer

Solution code:
import statistics

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

if n % 2 == 1:
  print(0)
  exit()
cnt = 0
index = 0
for _, num in enumerate(d):
  item = [j for j in d if j >= num]
  if len(item) == (len(d) / 2):
    cnt = num
    index = _

ans = 0
if cnt != 0:
  d = list(set(sorted(d)))
  ans = cnt - d[d.index(cnt) - 1]
print(ans)

Submission status: Wrong Answer

Solution code:
#ABCC - Divide the Problems
N = int(input())
d = list(map(int,input().split()))
d.sort()
n = N//2
a = d[0]
b = d[N-1]
ans = 0
for k in range(a,b,1):
    count = 0
    for i in range(N):
        if d[i] < k:
            count += 1
        else:
            break
    if count == n:
        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)):
    if len(list(filter(lambda i : i >= k, d)))==N/2:
        ans += 1
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys

n = int(input())
d = list(map(int, input().split()))
dic = {}
val = 0

for i in range(n):
    if d[i] in dic.keys():
        dic[d[i]] += 1
    else:
        dic[d[i]] = 1

dic = sorted(dic.items())

for i in range(len(dic) - 1):
    val += dic[i][1]
    if val == n//2:
        ans = (dic[i][0], dic[i+1][0])
        print(ans[1] - ans[0])
        break
    elif val > n//2:
        print(0)
        break

Submission status: Wrong Answer

Solution code:
n = int(input())
d = list(map(int,input().split()))
d.sort()
m = int(len(d)/2)
ml = d[m-1]
mr = d[m]

if mr - ml <= 1:
	print(0)
else:
	print(mr - ml)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
import copy
# import numpy as np

# ===FUNCTION===

def getInputNum():
    inputNum = int(input())
    return inputNum

def getInputListInt():
    outputoData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData

def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList

def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList

# ===CODE===

a = getInputNum()
b = getInputListInt()

c = sorted(b)

print(c)

mean = c[int(a/2)-1]
next = c[int(a/2 + 1)-1]



ans = next - mean

print(ans)

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

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

list_d_sorted = sorted(list_d)
jugde_num = N/2

cnt =0

for i in range(max(list_d)):
    index = bisect.bisect_left(list_d_sorted,i,)
    if index ==jugde_num:
        cnt +=1
print(cnt)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

num=0
ans=0
i=0
mid=len(d)/2
while num!=len(d)-1:
    i+=1
    while d[num]<i:
        num+=1
        if(num==len(d)-1):
            break
    if(num==mid):
        ans+=1
print(ans)

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
	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])
	print(D)

Submission status: Wrong Answer

Solution code:
import collections
N = int(input())
d = list(map(int,input().split()))
dd = sorted(d)
if d.count(dd[-(N//2)]) >1:
    print("0")
else:
    print(dd[-(N//2)]-dd[-(N//2)-1])

Submission status: Wrong Answer

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

print(arr)

center = n // 2

if(arr[center] == arr[center-1]):
    result = 0
else:
    result = arr[center] - arr[center-1]

print(result)

Submission status: Wrong Answer

Solution code:
N = int(input())
D = sorted(list(map(int, input().split())))
check = []
half = int(len(D)/2)
D_lead = D[:half]
D_tail = D[half:]
if max(D_lead) != min(D_tail):
    check = [num for num in range(max(D_lead), min(D_tail)+1)]
    print(len(check))
else:
    print(0)

Submission status: Wrong Answer

Solution code:
def divide_problems(n,d):
    ans = 0
    _d = sorted(d)
    print _d
    ans = _d[n/2] - _d[n/2-1]
#    print("fh %d, lh %d"  %(_d[n/2-1],_d[n/2]))
    return ans

if __name__ == '__main__':
    n = int(raw_input())
    d = list(map(int,raw_input().split()))

    print divide_problems(n,d)

Submission status: Wrong Answer

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


length = len(d)
length_half = int(length/2)


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

Submission status: Wrong Answer

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


print(d)

Submission status: Wrong Answer

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


print(d)

Submission status: Wrong Answer

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


print(d)

Submission status: Wrong Answer

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

nums.sort()
print(nums)

if n%2==1:
    print(0)
else:
    x=int((n/2)-1)
    y=int(n/2)
    a=nums[x]
    b=nums[y]
    s=b-a
    print(s)

Submission status: Wrong Answer

Solution code:

input()
xs = list(sorted(map(int, input().split())))

arc_idx = len(xs)//2
k_upper = xs[arc_idx]
k_lower = xs[arc_idx - 1] + 1

print(max(k_upper - k_lower, 0))

Submission status: Wrong Answer

Solution code:
n = int(input())
d = [int(i) for i in input().split()]
a = []
for i in range(min(d), max(d)):
    if len([0 for j in range(n) if d[j]<i])==len([0 for j in range(n) if d[j]>=i]):
        a.append(0)
print(len(a))

Submission status: Wrong Answer

Solution code:
n = int(input())
d = [int(i) for i in input().split()]
a = []
for i in range(max(d)):
    if len([0 for j in range(n) if d[j]<i])==len([0 for j in range(n) if d[j]>=i]):
        a.append(i)
print(len(a))

Submission status: Wrong Answer

Solution code:
n = int(input())
d = sorted([int(x) for x in input().split(' ')])
if d[int(n/2)-1] == d[int(n/2)]:
    print(0)
else:
    print(d[int(n/2)] - d[int(n/2)-1]+1)

Submission status: Wrong Answer

Solution code:
N = int(input())
d = [int(i) for i in input().split()]
K = max(d)
ans = 0

for i in range(K):
    temp_abc = 0
    temp_arc = 0
    for j in range(N):
        if d[j] >= i:
            temp_abc += 1
        else:
            temp_arc += 1
    if temp_abc == temp_arc:
        ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
def q38(n, d):
    max_d = max(d)
    min_d = min(d)
    count = 0
    for i in range(min_d+1, max_d):
        a = []
        b = []
        for j in d:
            if j >= i:
                a.append(j)
            else:
                b.append(j)
        if len(a) == len(b):
            count += 1
    return count
   
N = int(input())
d = [int(i) for i in input().split()]
print(q38(N, d))

Submission status: Wrong Answer

Solution code:
n = int(input())
d = input().split()
d = [int(d[i]) for i in range(n)]
d.sort()
a = 0
for g in range(d[-1]):
	nnn = len([i for i in range(n) if d[i]<g])
	if nnn==len(d)-nnn:
		a += 1
print(a)

Submission status: Wrong Answer

Solution code:
n = int(input())
d = input().split()
d = [int(d[i]) for i in range(n)]
d.sort()
a = 0
for g in range(d[-1]):
	if len([i for i in range(n) if d[i]<g])==len([i for i in range(n) if d[i]>=g]):
		a += 1
print(a)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#整数Nを得る
N = int(input())
#list  Pを得る
d = list(map(int,input().split()))

d.sort()
print(d)

k = int(N/2)
Ans = d[k] - d[k-1]

print(Ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

P=sorted(p)
print(P)
K=P[n//2]-P[n//2-1]

print(K)

Submission status: Wrong Answer

Solution code:
import io
import sys


def IN_S():
  return input()


def IN_I():
  return int(input())


def IN_L_I():
  return list(map(int, input().split()))


def IN_L_S():
  return list(map(str, input().split()))


def STR_SPLIT(s, n):
  for l in range(0, len(s), n):
    yield s[0 + l:n + l]


def T_IN():
  global test_str
  sys.stdin = io.StringIO(test_str[1:-1])


test_str = '''
6
9 1 4 4 6 7
'''

def MAIN():
  T_IN()
  A()


def A():
  num = IN_I()
  lists = IN_L_I()
  lists.sort()

  print(lists[num // 2] - lists[num // 2 - 1])
  return None


def B():
  return None


def C():
  return None


MAIN()

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    d = list(map(int, input().split()))
    d.sort()
    
    answer = 0
    K = max(d)
    
    for k in range(K):
        count = 0
        
        for d_i in d:
            if d_i < k:
                count += 1
            else:
                count -= 1
                
        if count == 0:
            answer += 1
                
    print(answer)
    
if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N=int(input())
L=list(input().split())
NL=sorted(L)
P=int(NL[int(N/2)-1])
Q=int(NL[int(N/2)])
print(Q+1-P)

Submission status: Wrong Answer

Solution code:
N=int(input())
L=list(input().split())
L=sorted(L)
P=int(L[int(N/2)-1])
Q=int(L[int(N/2)])
print(Q+1-P)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if len(d) % 2 != 0:
    print(0)
else:
    print(d[int(len(d) / 2)])

Submission status: Wrong Answer

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

print(len(d) / 2)

Submission status: Wrong Answer

Solution code:
N = int(input())
d = list(map(int, input().split()))
""" 
d = [9, 1, 4, 4, 6, 7]
#N = 8
N = 6
#d = [9, 1, 14, 5, 5, 4, 4, 14]
d = [9, 1, 4, 4, 6, 7]
 """
# prob
# [number,value]
prob = []
cnt = 0
for i in d:
    prob.append([cnt, i])
    cnt += 1

""" print(prob)
print(sorted(prob, key=lambda x: x[1]))
 """
sorted_d = sorted(prob, key=lambda x: x[1])

#print(d_min, d_max)

# if len(sorted_d[0:i]) == len(sorted_d[i:]):
cnt += sorted_d[int(N/2)][1] - sorted_d[int(N/2-1)][1]

print(cnt)

Submission status: Wrong Answer

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

d = [9, 1, 4, 4, 6, 7]
#N = 8
N = 6
#d = [9, 1, 14, 5, 5, 4, 4, 14]
d = [9, 1, 4, 4, 6, 7]

# prob
# [number,value]
prob = []
cnt = 0
for i in d:
    prob.append([cnt, i])
    cnt += 1

""" print(prob)
print(sorted(prob, key=lambda x: x[1]))
 """
sorted_d = sorted(prob, key=lambda x: x[1])

d_max = sorted_d[N-1][1]
d_min = sorted_d[0][1]
#print(d_min, d_max)

cnt = 0
for i in range(N):
    """ print(sorted_d[0:i])
    print(sorted_d[i:])
 """
    if len(sorted_d[0:i]) == len(sorted_d[i:]):
        """ print("True")
        print(sorted_d[i][1])
        print(sorted_d[i-1][1])
        print(sorted_d[i][1] - sorted_d[i-1][1])
         """
        cnt += sorted_d[i][1] - sorted_d[i-1][1]
    # print("------")

print(cnt)

Submission status: Wrong Answer

Solution code:
def q38(n, d):
    max_d = max(d)
    min_d = min(d)
    count = 0
    for i in range(min_d+1, max_d):
        a = []
        b = []
        for j in d:
            if j >= i:
                a.append(j)
            else:
                b.append(j)
        if len(a) == len(b):
            count += 1
    return count

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

Submission status: Wrong Answer

Solution code:
N = int(input())
d = list(map(int,input().split()))
t = 0
for i in range(max(d)):
    d1 = [x for x in d if x>=i]
    if len(d1)==N//2:
        t += 1

print(t)

Submission status: Wrong Answer

Solution code:
N = int(input())
d = list(map(int,input().split()))
t = 0
for i in range(max(d)):
    d1 = [x for x in d if x>=i]
    d2 = [x for x in d if x<i]
    if len(d1)==len(d2):
        t += 1

print(t)

Submission status: Wrong Answer

Solution code:
N = int(int(input())/2)
l = list(map(int,input().split()))
l.sort()
ans = 0
for k in range(max(l)):
  ABC = sum(x<k for x in l)
  if ABC == N:
    ans+=1
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

N = int(input())
data = np.array(list(map(int, input().split())))
dmax = data.max()

cnt = 0
for i in range(dmax):
    low = 0
    high = 0
    for d in data:
        if(i > d): low += 1
        else: high += 1
    if(low == high): cnt += 1
print(cnt)

Submission status: Wrong Answer

Solution code:
# C - Divide the Problems

N = int(input())
data = list(map(int, input().split()))
if N % 2 == 1:
    print(0)
else:
    big = max(data)
    small = min(data)
    half = int(N / 2)
    ans = 0
    for i in range(small, big):
        count = 0
        for j in range(N):
            if i > data[j]:
                count += 1
        if count == half:
            ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
# C - Divide the Problems

N = int(input())
data = list(map(int, input().split()))
if N % 2 == 1:
    print(0)
else:
    big = max(data)
    small = min(data)
    # 演算

Submission status: Wrong Answer

Solution code:
n = int(input())

d = input().split(" ")

for i in range(n):
    d[i] = int(d[i])

ans = 0
for i in range(max(d)):
    arc = [d[j] for j in range(n) if d[j] < i]
    abc = [d[j] for j in range(n) if d[j] >= i]
    if len(arc) == len(abc):
        ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
import random
import numpy as np

N = int(input())
d = [int(i) for i in input().split()]
dd = np.sort(d,kind='quicksort')

K = N / 2
K = dd[K]

print(K)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N = int(input())
s = list(map(int, input().split())) 
nums =[0,0]
num = 0
s_max = max(s)
s_min = min(s)

for K in range(s_max):
    for i in range(N):
        if s[i] >= K:
            nums[0] = nums[0] +1
        else:
            nums[1] = nums[1] +1
    if nums[0] == nums[1]:
        num = num+1
    else:
        pass
    nums =[0,0]

print(num)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
d = list(int(i) for i in input().split())
ans = 0

for i in range(n-2):
  if (d[i] < d[i+1] and d[i+1] < d[i+2]) or (d[i] > d[i+1] and d[i+1] > d[i+2]):
      ans += 1


print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
d = list(map(int,input().split()))
k = max(d)
i = 0
j = 0
ans = 0
b = 0
s = 0
while i <= k:
  while j <= n-1:
    if d[j] < i:
      s += 1
    if d[j] >= i:
      b += 1
    j += 1
  if b == s:
    ans += 1
  b = 0
  s = 0
  i += 1
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
d = list(map(int,input().split()))
k = max(d)
i = 0
j = 0
ans = 0
b = 0
s = 0
while i <= k:
  while j <= n-1:
    if d[j] < i:
      b += 1
      j += 1
    if d[j] >= i:
      s += 1
      j += 1
  if b == s:
    ans += 1
  b = 0
  s = 0
  i += 1
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
d = list(map(int,input().split()))
k = max(d)
i = 0
j = 0
ans = 0
b = 0
s = 0
while i <= k:
  while j <= n-1:
    if d[j] <= i:
      b += 1
      j += 1
    if d[j] > i:
      s += 1
      j += 1
  if b == s:
    ans += 1
  b = 0
  s = 0
  i += 1
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
p = list(map(int, input().split()))
count = 0
for x in range(2, n):
    if(p[x-2] < p[x-1] and p[x] > p[x-1]):
        count += 1
    elif(p[x-2] > p[x-1] and p[x] < p[x-1]):
        count += 1
print(count)

Submission status: Wrong Answer

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

d.sort()
set_count = 0

for x in range(d[n - 1]):
    count = 0
    for y in range(int(n / 2) + 1):
        if x > d[y]:
            count += 1

    if count == int(n / 2):
        set_count += 1

print(set_count)

Submission status: Wrong Answer

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

d.sort()
set_count = 0

for x in range(d[n - 1]):
    count = 0
    for y in range(n):
        if x > d[y]:
            count += 1

    if count == int(n / 2):
        set_count += 1


print(set_count)

Submission status: Wrong Answer

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

#import numpy
#m=int(numpy.median(d)-2)

y=sorted(d)
z=len(d)
w=int(z/2)

m=y[w-1]

ans=0
flag=0
for K in range(m,d_max):
    arc=0
    abc=0
    if flag==1:
        break
    for i in range(len(d)):
        if(K > d[i]):
            abc+=1
        if(K <= d[i]):
            arc+=1
        if(abc > len(d)/2):
            flag=1
            break
        #print(arc,abc,ans,j,d[i])
    if abc==arc:
        ans+=1
print(ans)

Submission status: Wrong Answer

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

ans=0
flag=0
for K in range(d_max):
    arc=0
    abc=0
    if flag==1:
        break
    for i in range(len(d)):
        if(K > d[i]):
            abc+=1
        if(K <= d[i]):
            arc+=1
        if(abc > len(d)/2):
            flag=1
            break
        #print(arc,abc,ans,j,d[i])
    if abc==arc:
        ans+=1
print(ans)

Submission status: Wrong Answer

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

ans=0

for j in range(d_max):
    arc=0
    abc=0
    for i in range(len(d)):
        if(j > d[i]):
            abc+=1
        if(j <= d[i]):
            arc+=1
        if(abc > len(d)/2):
            break
        if(arc > len(d)/2):
            break
        #print(arc,abc,ans,j,d[i])
    if abc==arc:
        ans+=1
print(ans)

Submission status: Wrong Answer

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

ans=0

for j in range(d_max):
    arc=0
    abc=0
    for i in range(len(d)):
        if(j > d[i]):
            abc+=1
        if(j <= d[i]):
            arc+=1
        if(abc > len(d)/2+2):
            break
        if(arc > len(d)/2+2):
            break

        #print(arc,abc,ans,j,d[i])
    if abc==arc:
        ans+=1
print(ans)

Submission status: Wrong Answer

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


ans=0

for j in range(d_max):
    arc=0
    abc=0
    for i in range(len(d)):
        if(j > d[i]):
            abc+=1
        if(j <= d[i]):
            arc+=1

        #print(arc,abc,ans,j,d[i])
    if abc==arc:
        ans+=1
print(ans)

Submission status: Wrong Answer

Solution code:
input_line=int(input())
ARC = [int(i)for i in input().split()]
ABC = []
t =max(ARC)
count=0
for i in range(t):
  AARC = ARC
  AABC = ABC
  for s in ARC:
    if s < i :
      AABC.append(s)
      AARC.remove(s)
      while s in AARC:
        AABC.append(s)
        AARC.remove(s)
  if len(AABC) == len(AARC):
    count+=1

print(count)

Submission status: Wrong Answer

Solution code:
input_line=int(input())
ARC = [int(i)for i in input().split()]
ABC = []
s =max(ARC)
count=0
for i in range(s):
  AARC = ARC
  AABC = ABC
  for s in ARC:
    if s < i :
      AABC.append(s)
      AARC.remove(s)
      if s in AARC:
        AABC.append(s)
        AARC.remove(s)
  if len(AABC) == len(AARC):
    count+=1

print(count)

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
  z = int(input())
  if 10000 >= z and z >= 2 and z%2==0:
    rank_list = list(map(int, input().strip().split()))
    if 10000 >= all(rank_list) and all(rank_list) >= 1:
      rank_sort = sorted(rank_list)
      num = int(len(rank_sort)/2)
      arc = rank_sort[:num]
      abc = rank_sort[num:]
      dif = min(abc) - max(arc)
      if len(arc) == len(abc):
          print(min(abc) - max(arc))

Submission status: Wrong Answer

Solution code:
if __name__ == '__main__':
  z = int(input())
  if 10000 >= z and z >= 2 and z%2==0:
    rank_list = list(map(int, input().strip().split()))
    rank_sort = sorted(rank_list)
    num = int(len(rank_sort)/2)
    arc = rank_sort[:num]
    abc = rank_sort[num:]
    dif = min(abc) - max(arc)
    if len(arc) == len(abc):
    	print(min(abc) - max(arc) -1 )