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:
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:]
    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()))
    count = 0
    rank_sort = sorted(rank_list)
    num = int(len(rank_sort)/2)
    arc = rank_sort[:num]
    abc = rank_sort[num:]
    print(min(abc) - max(arc))

Submission status: Wrong Answer

Solution code:
# Check Examples

#python 3.7.1

n=int(input())
p=input().split()  
p=list(map(int,p))          
cnt=0

for i in range(1,n+1):
	arc=[z for z in p if z>=i]
	abc=[z for z in p if z<i]
	if len(arc)==len(abc):cnt+=1
	if len(arc)<len(abc):break

print (cnt)

Submission status: Wrong Answer

Solution code:
# Check Examples

#python 3.7.1

n=int(input())
p=input().split()  
p=list(map(int,p))          
cnt=0

for i in range(1,n+1):
	arc=[z for z in p if z>=i]
	abc=[z for z in p if z<i]
	if len(arc)==len(abc):cnt+=1

print (cnt)

Submission status: Wrong Answer

Solution code:
N=int(input())
D=[int(i) for i in input().split()]
D=sorted(D)
nanko=0
for i in range(D[N-1]):
    if(D[int(N/2)-1]<i and D[int(N/2)]>=i):
        nanko+=1
print(nanko)

Submission status: Wrong Answer

Solution code:
N=int(input())
D=[int(i) for i in input().split()]
D=sorted(D)
nanko=0
for i in range(D[N-1]):
    if(D[int(N/2-1)]<i and D[int(N/2)]>=i):
        nanko+=1
print(nanko)

Submission status: Wrong Answer

Solution code:
def is_even(num):
    if num % 2 == 0:
        return True
    else:
        return False

def is_odd(num):
    if num % 2 == 1:
        return True
    else:
        return False


n=int(input())


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

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

    else:
        print(d[LEN]-d[LEN-1]+1)

elif is_odd(LEN):
    if d[LEN]==d[LEN-1]:
        print(0)

    else:
        print(d[LEN]-d[LEN-1])

Submission status: Wrong Answer

Solution code:
def is_even(num):
    if num % 2 == 0:
        return True
    else:
        return False

def is_odd(num):
    if num % 2 == 1:
        return True
    else:
        return False


n=int(input())


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

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

    else:
        print(d[LEN]-d[LEN-1]+1)

elif is_odd(LEN):
    print(d[LEN]-d[LEN-1])

Submission status: Wrong Answer

Solution code:
def is_even(num):
    if num % 2 == 0:
        return True
    else:
        return False

def is_odd(num):
    if num % 2 == 1:
        return True
    else:
        return False


n=int(input())


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

d=sorted(d)
LEN=int(len(d)/2)
if is_even(LEN):
    print(d[LEN]-d[LEN-1]+1)

elif is_odd(LEN):
    print(d[LEN]-d[LEN-1])

Submission status: Wrong Answer

Solution code:
n = int(input())
d = list(map(int,input().split()))
d = sorted(d)
num = []
cnt = 0
num.append(d[0])
d.pop(0)
num_len=1
d_len=n-1

for i in range(num[0], d[-1]):
  if len(d)==0:
    print(0)
    exit()
    
  if num[-1]<=d[0]:
    tmp = d.count(d[0])
    a = d[0]
    num.extend(d[0:tmp])
    del d[0:tmp]
    num_len+=tmp
    d_len-=tmp
  if num_len==d_len:
    cnt = d[0] - num[-1]
    print(cnt)
    exit()

Submission status: Wrong Answer

Solution code:
N = int(input())
num=input()
numlist = num.split(" ")
numlist.sort()
index=int(N/2)
ans = int(numlist[index]) - int(numlist[index-1])
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
num=input()
numlist = num.split(" ")
numlist.sort()
print(numlist)
index=int(N/2)
ans = int(numlist[index]) - int(numlist[index-1])
print(ans)

Submission status: Wrong Answer

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

d.sort()

#for i in range(int(d[int(N/2)-1]),int(d[int(N/2)]+1)):

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

print(ans)

Submission status: Wrong Answer

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

for i in range(int(max(d))):
    ABC=0
    ARC=0
    for j in range(int(N)):
        
        if d[j]<i:
            ABC+=1
        elif d[j]>=i:
            ARC+=1

    if ARC==ABC:
        ans+=1

print(ans)

Submission status: Wrong Answer

Solution code:
n = input()
p = []
input_first = input()
for ki in range(int(n)):
    p = input_first.rstrip().split(' ')
count = 0
temp = 0
q = []
for k in range(len(p)):
    q.append(int(p[k]))
for i in range(min(q),max(q)):
    for j in range(len(q)):
        if q[j] >= i:
            temp += 1
        elif q[j] < i:
            temp -= 1
    if temp == 0:
        count += 1
    else:
        pass
    temp = 0
print(count)

Submission status: Wrong Answer

Solution code:
n = int(input())

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

sorted_diffs = sorted(diffs)
abc = 0
arc = 0
result = 0

for i in range(sorted_diffs[-1]):
    abc = 0
    arc = 0
    for diff in sorted_diffs:
        if diff < i:
            abc += 1
        else:
            arc += 1
    if abc != 0 and abc == arc:
        result += 1
    elif abc > arc:
        print(result)
        exit()

print(result)

Submission status: Wrong Answer

Solution code:
n = int(input())

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

sorted_diffs = sorted(diffs)
abc = []
arc = []
result = 0

for i in range(sorted_diffs[-1]):
    abc.clear()
    arc.clear()
    for diff in sorted_diffs:
        if diff < i:
            abc.append(diff)
        else:
            arc.append(diff)
    if len(abc) != 0 and len(abc) == len(arc):
        result += 1
    elif len(abc) > len(arc):
        print(result)
        exit()

print(result)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import bisect

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

d.sort()
ans = 0

for k in range(max(d)):
  i = bisect.bisect_left(d,k)
  if i == n - i:
    ans += 1
    
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
d = list(map(int,input().split()))
dunder = 0
count = 0
for i in range(max(d)):
    dunder = sum (x<i for x in d)
    if 2*dunder == len(d):
        count += 1
    elif 2*dunder > len(d):
        break
print(count)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n = int(input())
d = list(map(int,input().split()))
d.sort()
while len(d) > 0:
        x = d.pop()
        y = d.pop(0)
print(y - x)

Submission status: Wrong Answer

Solution code:
N = int(input())
d = list(map(int,input().split()))
dunder = 0
count = 0
for i in range(N):
    dunder = sum (x<i for x in d)
    if 2*dunder == len(d):
        count += 1
    elif 2*dunder > len(d):
        break
print(count)

Submission status: Wrong Answer

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

count = 0

if n % 2 == 0:
    d.sort()
    print(d)
    tmp = n  // 2

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

    else:
        print(d[tmp]-d[tmp-1])

else:
    print(0)

Submission status: Wrong Answer

Solution code:
N = int(input())
d = list(map(int,input().split()))
dunder = 0
count = 0
for i in range(max(d)):
    dunder = sum (x<i for x in d)
    if 2*dunder == len(d):
        count += 1
print(count)

Submission status: Wrong Answer

Solution code:
N = int(input())
d = list(map(int,input().split()))
dunder = 0
count = 0
for i in range(max(d)):
    dunder = sum (x<i for x in d)
    print(dunder)
    if 2*dunder == len(d):
        count += 1
print(count)

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:
import sys
import bisect
input = sys.stdin.readline

N = int(input())
L = [int(v) for v in input().split()]
L.sort()

ans = 0
n = N // 2
for v in range(2, L[-1]):
    if n == bisect.bisect_left(L, v):
        ans += 1
        
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def calc(ds) -> int:
  min_ = min(ds)
  max_ = max(ds)
  half = len(ds) // 2
  usable_count = 0
  for i in range(min_, max_):
    abc_using = [d for d in ds if d < i]
    if len(abc_using) == half:
      usable_count += 1
  
  return usable_count

_ = input()
numbers_str = input()
result = calc([int(n) for n in numbers_str.split(' ')])
print(result)

Submission status: Wrong Answer

Solution code:
def prob_c():
    n = int(input())
    d_list = [int(a) for a in input().split()]
    for i in range(int(n/2 + 0.1)):
        if i == 0:
            mid_min = min(d_list[0], d_list[1])
            mid_max = max(d_list[0], d_list[1])
        else:
            if max(d_list[i*2], d_list[i*2 + 1]) < mid_min:
                mid_max = mid_min
                mid_min = max(d_list[i*2], d_list[i*2 + 1])
            elif min(d_list[i*2], d_list[i*2 + 1]) > mid_max:
                mid_min = mid_max
                mid_max = min(d_list[i*2], d_list[i*2 + 1])
            else:
                mid_max = min(mid_max, max(d_list[i*2], d_list[i*2 + 1]))
                mid_min = max(mid_min, min(d_list[i*2], d_list[i*2 + 1]))
    return mid_max - mid_min

b = prob_c()
print(str(b))

Submission status: Wrong Answer

Solution code:
n = int(input())
d = list(map(int,input().split()))
ans = 0
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:
        ans +=1
    else:
        continue
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)):
    ARC = 0
    ABC = 0
    for i in range(n):
        if d[i] >= k:
            ARC += 1
        else:
            ABC += 1
    if ARC == ABC:
        ans +=1
        print(k,ans)
    else:
        print(k,ans,ARC,ABC)
        continue
print(ans)

Submission status: Wrong Answer

Solution code:
from collections import Counter
n = int(input())
d_array = [int(x) for x in input().split()]
d_counter = Counter(d_array)

small = 1
large = n-small
now = min(d_array)
now_index = 0
cnt = 0
for i in range(max(d_array)):
    if small == n//2:
        cnt += 1
    if i > now:
        now_index += 1
        now = i
        small += d_counter[i]
        large -= d_counter[i]
print(cnt)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n1=int(input())
n2 = [int(x) for x in input().split()]

cnt = 0

for i in range(len(n2)):
  if n1 < n2[i]:
    cnt += 1
    
print(cnt)

Submission status: Wrong Answer

Solution code:
n1=int(input())
n2 = [int(x) for x in input().split()]

cnt = 0

for i in range(len(n2)):
  print(n2[i])
  if n1 < n2[i]:
    cnt += 1
    
print(cnt)

Submission status: Wrong Answer

Solution code:
n = int(input())
P = map(int,input().split())
p = [i for i in P]
p.sort()
if n % 2 == 1:
    print(0)
elif len(p) == 2:
    if p[0]==p[1]:
        print(0)
    else:
        print(1)
else:
    if p[(n//2)] == p[(n//2)-1]:
        print(0)
    else:
        print(p[n//2]-p[(n//2)-1])

Submission status: Wrong Answer

Solution code:
p = int(input())
n = list(map(int, input().split()))
 
c=0
x = 0
#iでnを回す
for k in range(p):
  #kはなんだろ
  for i in range(p):
    if(k > n[i]):
      x += 1
      if(x == p/2):
        c += 1
        x = 0
      else:
        x = 0
print(c)

Submission status: Wrong Answer

Solution code:
n = input()
nums = input().split(' ')
print(nums)
nums = [int(num) for num in nums]
cnt=0

for i in range(1,len(nums)-1):
  
  print(nums[i-1], nums[i], nums[i+1])
  if nums[i-1] < nums[i] and nums[i] < nums[i+1]:
    cnt += 1
    print('OK')
  if nums[i+1] < nums[i] and nums[i] < nums[i-1]:
    cnt += 1
    print('OK')
      
print(cnt)

Submission status: Wrong Answer

Solution code:
n1=int(input())
n2 = [int(x) for x in input().split()]

cnt = 0

for i in range(len(n2)):
  if n1 > n2[i]:
    cnt += 1
    
print(cnt)

Submission status: Wrong Answer

Solution code:
n = int(input())
P = map(int,input().split())
p = [i for i in P]
p.sort()
if n % 2 == 1:
    print(0)
elif len(p) == 2:
    if p[0]==p[1]:
        print(0)
    else:
        print(1)
else:
    a = p[n//2]
    if a == p[(n//2)-1] or a == p[(n//2)+1]:
        print(0)
    else:
        print(p[n//2]-p[(n//2)-1])

Submission status: Wrong Answer

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

c=0
x = 0
#iでnを回す
for k in range(p):
  #kはなんだろ
  for i in range(p):
    if(k > n[i]):
      x += 1
      if(x == p/2):
        c += 1
        x = 0
print(c)

Submission status: Wrong Answer

Solution code:
import math

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

d_i_set = sorted(set(sorted(d_i)))
a = d_i_set[math.floor(len(d_i_set) / 2)]
b = d_i_set[math.floor(len(d_i_set) / 2) - 1]

a1 = [i for i in d_i if i >= a]
b1 = [i for i in d_i if i <= b]

if len(a1) == len(b1):
    print(a - b)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
import sys 
import numpy as np
def divide():
    N=int(input())
    d=list(map(int,input().split()))
    d=np.array(d)
    countour=0
    countourf1=0
    countourf2=0
    max=d.max()
    for i in range(1,max):
        x=np.where(d < i, 0,1)
        for y in range(0,N):
            if x[y] ==0:
                countourf1+=1
            else :
                countourf2+=1
    
        if countourf1==countourf2:
            countour+=1
        if (countourf1 > (N/ 2) ):
            break
            
        countourf1=0
        countourf2=0    
            
    print(countour)


divide()

Submission status: Wrong Answer

Solution code:
import bisect

n = int(input())
d = list(int(x) for x in input().split())
d.sort()

ans = 0

for k in range(min(d), max(d)):
    if bisect.bisect_left(d, k) == n // 2:
        ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
P = map(int,input().split())
p = [i for i in P]
p.sort()
print(p)
if n % 2 == 1:
    print(0)
elif len(p) == 2:
    if p[0]==p[1]:
        print(0)
    else:
        print(1)
else:
    a = p[n//2]
    if a == p[(n//2)-1] or a == p[(n//2)+1]:
        print(0)
    else:
        print(p[n//2]-p[(n//2)-1])

Submission status: Wrong Answer

Solution code:
import statistics

n = int(input())
d = list(map(int,input().split())) 
med = statistics.median(d)
if med%2 == 0:
    print(0)
else:
    print(2)

Submission status: Wrong Answer

Solution code:
n = int(input())
d = list(map(int,input().split()))
p = 0
q = 0
m = 0
d.sort()
if (len(d))%2 == 0:
  m = (d[(len(d)//2)-1]+d[len(d)//2])/2
else:
  m = d[(len(d)//2)]
for i in range(len(d)):
  if d[i]>=m:
    if d[i] == d[i+1]:
      break
    else:
      p = d[i]
      q = d[i-1]
      break
  else:
    break
print(p-q)

Submission status: Wrong Answer

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

import statistics
t = len(d) / 2
k_low = statistics.median_low(d)
k_high = statistics.median_high(d)

c = 0
C = 0

if k_low == k_high:
    C = C - 1
else:
    C = C

for i in d:
    if i <= k_low:
        c +=1
    else:
        c+=0
        
if c == t:
    C += 1
else:
    C += 0

c = 0
for i in d:
    if i >= k_high:
        c +=1
    else:
        c+=0
        
if c == t:
    C += 1
else:
    C += 0

if C < 0:
    C = 0

print(C)

Submission status: Wrong Answer

Solution code:
n = int(input())
d = list(map(int,input().split()))
p = 0
q = 0
m = 0
d.sort()
if (len(d))%2 == 0:
  m = ((d[(len(d)//2)])+(d[len(d)//2-1]))/2
else:
  m = d[(len(d)//2)]
for i in range(len(d)):
  if d[i]>=m:
    if d[i] == d[i+1]:
      break
    else:
      p = d[i]
      q = d[i-1]
      break
  else:
    break
print(p-q)

Submission status: Wrong Answer

Solution code:
n=input()
s=input()
s=s.replace(" ","")
x=0
for i in range(int(n)):
  a=0
  b=0
  for j in range(int(n)):
    if int(s[j])>=i+1:
      a=a+1
    else:
      b=b+1
  if a==b:
    x=x+1
print(x)

Submission status: Wrong Answer

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

cnt = 0
for K in range(max(d)):
    ARC = [i for i in d if K <= i]
    ABC = [i for i in d if i < K]
    if len(ARC) == len(ABC):
        cnt += 1
print(cnt)

Submission status: Wrong Answer

Solution code:
import numpy as np

size=input()
pro=input()

p=np.array(pro.split(" "),dtype=np.int32)
p=np.sort(p)

k_end=p[-1]
k_start=p[0]

check=p[int(len(p)/2)]

c=0
for k in range(k_start,k_end):
    if(check+1<k):
        break
    a=len(p[k<=p])
    b=len(p)-a
    if(a==b):
        c+=1
    else:
        pass
print(c)

Submission status: Wrong Answer

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

import statistics
t = len(d) / 2
k_low = statistics.median_low(d)
k_high = statistics.median_high(d)

c = 0
C = 0

if k_low == k_high:
    C = C - 1
else:
    C = C

for i in d:
    if i <= k_low:
        c +=1
    else:
        c+=0
        
if c == t:
    C += 1
else:
    C += 0

c = 0
for i in d:
    if i >= k_high:
        c +=1
    else:
        c+=0
        
if c == t:
    C += 1
else:
    C += 0





print(C)

Submission status: Wrong Answer

Solution code:
import sys 
import numpy as np
def divide():
    N=int(input())
    d=list(map(int,input().split()))
    d=np.array(d)
    countour=0
    countourf1=0
    countourf2=0
    max=d.max()
    for i in range(1,max):
        x=np.where(d < i, 0,1)
        for y in range(0,N):
            if x[y] ==0:
                countourf1+=1
            else :
                countourf2+=1
    
        if countourf1==countourf2:
            countour+=1
        if (countourf1 > (max/ 2) )or (countourf2 > (max/2) ):
            break
            
        countourf1=0
        countourf2=0    
            
    print(countour)

Submission status: Wrong Answer

Solution code:
import numpy as np

size=input()
pro=input()

p=np.array(pro.split(" "),dtype=np.int32)
p=np.sort(p)

k_end=p[-2]
k_start=p[1]

check=p[int(len(p)/2)]

c=0
for k in range(k_start,k_end):
    if(check+1<k):
        break
    a=len(p[k<=p])
    b=len(p)-a
    if(a==b):
        c+=1
    else:
        pass
print(c)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(100000)


N = int(input())
D = [int(i) for i in input().split()]
cnt = 0

max_ = 100000

Ks = set()
cnt = 0

jump = 10000


def dev(K, jmp):

    global cnt
    # print(K)
    if K in Ks:
        return -1
    hicnt = 0
    locnt = 0
    Ks.add(K)
    for d in D:
        if d >= K:
            hicnt += 1
        else:
            locnt += 1

    if hicnt == locnt:
        cnt += 1
        if jmp > 1:
            dev(K+jmp, round(jmp/2))
            dev(K-jmp, round(jmp/2))
        else:
            dev(K+jmp, 1)
            dev(K-jmp, 1)
        return 0

    if hicnt < locnt:
        dev(round(K/2), jmp)
        return 1
    else:
        dev(round(K + (max_ - K)/2), jmp)
        return 2


def main():
    dev(round(max_/2), jump)
    print(cnt)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

import statistics
t = len(d) / 2
k_low = statistics.median_low(d)
k_high = statistics.median_high(d)

c = 0
C = 0
for i in d:
    if i <= k_low:
        c +=1
    else:
        c+=0
        
if c == t:
    C += 1
else:
    C += 0

c = 0
for i in d:
    if i > k_high:
        c +=1
    else:
        c+=0
        
if c == t:
    C += 1
else:
    C += 0
    
print(C)

Submission status: Wrong Answer

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

import statistics
t = len(d) / 2
k_low = statistics.median_low(d)
k_high = statistics.median_high(d)

c = 0
C = 0
for i in d:
    if i < k_low:
        c +=1
    else:
        c+=0
        
if c == t:
    C += 1
else:
    C += 0

c = 0
for i in d:
    if i >= k_high:
        c +=1
    else:
        c+=0
        
if c == t:
    C += 1
else:
    C += 0
    
print(C)

Submission status: Wrong Answer

Solution code:
import numpy as np

size=input()
pro=input()

p=np.array(pro.split(" "),dtype=np.int32)
p=np.sort(p)

k_end=p[-2]
k_start=p[1]

check=p[int(len(p)/2)]

c=0
for k in range(k_start,k_end+1):
    if(check+1<k):
        break
    a=len(p[k<=p])
    b=len(p[k>p])
    if(a==b):
        c+=1
    else:
        pass
print(c)

Submission status: Wrong Answer

Solution code:
n=input()
s=input()
s=s.replace(" ",",")
s=str(s).split(",")
l=list(s)
x=0
for i in range(int(n)):
  a=0
  b=0
  for j in range(int(n)):
    if int(l[j])<i:
      a=a+1
    else:
      b=b+1
  if a==b:
    x=x+1
print(x)

Submission status: Wrong Answer

Solution code:
import bisect

n = int(input())
d = list(int(x) for x in input().split())
d.sort()

ans = 0

for k in range(min(d), max(d)):
    idx = bisect.bisect_left(d, k)
    if idx == n // 2:
        ans += 1

print(ans)

Submission status: Wrong Answer

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

import statistics
t = len(d) / 2
k_low = statistics.median_low(d)
k_high = statistics.median_high(d)

c = 0
C = 0
for i in d:
    if i <= k_low:
        c +=1
    else:
        c+=0
        
if c == t:
    C += 1
else:
    C += 0

c = 0
for i in d:
    if i >= k_high:
        c +=1
    else:
        c+=0
        
if c == t:
    C += 1
else:
    C += 0
    
print(C)

Submission status: Wrong Answer

Solution code:
import sys

N = int(input())
D = [int(i) for i in input().split()]
cnt = 0

max_ = 100000

Ks = set()
cnt = 0

jump = 10000


def dev(K, jmp):

    global cnt
    #print(K)
    if K in Ks:
        return -1
    hicnt = 0
    locnt = 0
    Ks.add(K)
    for d in D:
        if d >= K:
            hicnt += 1
        else:
            locnt += 1

    if hicnt == locnt:
        cnt += 1
        if jump > 1:
            dev(K+jmp, round(jmp/2))
            dev(K-jmp, round(jmp/2))
        else:
            dev(K+jmp, 1)
            dev(K-jmp, 1)
        return 0

    if hicnt < locnt:
        dev(round(K/2), jmp)
        return 1
    else:
        dev(round(K + (max_ - K)/2), jmp)
        return 2


def main():
    dev(round(max_/2), jump)
    print(cnt)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import sys 
import numpy as np
def divide():
    N=int(input())
    d=list(map(int,input().split()))
    d=np.array(d)
    countour=0
    countourf1=0
    countourf2=0
    max=d.max()
    for i in range(1,max):
        x=np.where(d < i, 0,1)
        for y in range(0,N):
            if x[y] ==0:
                countourf1+=1
            else :
                countourf2+=1
    
        if countourf1==countourf2:
            countour+=1
        countourf1=0
        countourf2=0    
            
    print(countour)


divide()

Submission status: Wrong Answer

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

dmin = min(d)
dmax = max(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 or count2 > N / 2:
            break

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

print(count3)

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
    num_list = [i for i in d if i >= k]
    if len(num_list) == half:
        ans += 1
    # for i in d:
    #     if i >= k:
    #         cnt += 1

    # if cnt == half:
    #     ans += 1

print(ans)

Submission status: Wrong Answer

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

round=lambda x:(x*2+1)//2

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

ans = 0
testd = []

for i in range(max(d)):
    testd = copy.copy(d)
    testd.append(i)
    testd.sort()
    index_num = [n for n, v in enumerate(testd) if v == i]
    ix_max = max(index_num)
    ix_min = min(index_num)
    #print(i,ix_max,ix_min,round(len(testd)/2)-1)
    #if ix_max == round(len(testd)/2)-1 or ix_min == round(len(testd)/2)-1:
    if ix_min == round(len(testd)/2)-1:
        #print(testd)
        #print(i,ix_max,ix_min,round(len(testd)/2)-1,len(testd)/2)
        ans = ans + 1

print(ans)

Submission status: Wrong Answer

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

res_count = 0

for i in range(0, N-1):
    d_ave = sum([d_list[i], d_list[i+1]]) / 2
    ARC_list = [d for d in d_list if d_ave <= d]
    ABC_list = [d for d in d_list if d_ave > d]
    # print('{} {} {}'.format(d_ave, ARC_list, ABC_list))
    
    if( len(ARC_list) == len(ABC_list) ):
        for K in range(d_list[i], d_list[i+1]+1):
            ARC = 0
            ABC = 0
            for d in d_list:
                if( d >= K ):
                    ARC += 1
                else:
                    ABC += 1
            if( ARC == ABC ):
                res_count += 1

print(res_count)

Submission status: Wrong Answer

Solution code:
k = 0
a = input()

lista = input().split(" ")
lista.sort()

for i in range(int(lista[0]), int(lista[-1])):
    listamax = []
    listamin = []
    for j in lista:
        if(int(j)>=int(i)):
            listamax.append(j)
        else:
            listamin.append(j)
    if(len(listamax)==len(listamin)):
        k+=1
print(k)

Submission status: Wrong Answer

Solution code:
def dfs(left, right):
    if right <= left:
        return 0
    mid = (left + right) // 2
    ret = 0
    ret += dfs(left, mid)
    ret += dfs(mid+1, right)

    abc = arc = 0
    for i in range(N):
        if d[i] < mid:
            abc += 1
        else:
            arc += 1
    if abc == arc:
        ret += 1

    return ret


def main():
    global N
    N = int(input())
    global d
    d = list(map(int, input().split()))
    d.sort()
    global K
    K = []
    for i in range(d[0], d[N-1]+1):
        K.append(i)
    ans = dfs(K[0], K[-1])
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:

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

cnt = 0

var1 = int((min(d) + max(d)) / 2)
var2 = var1-1

def func(k):
    abc = 0
    arc = 0
    for i in d:
        if k <= i:
            arc+=1
        else:
            abc+=1
    return arc==abc
    
while func(var1):
    cnt+=1
    var1+=1

while func(var2):
    cnt+=1
    var2-=1

print(cnt)

Submission status: Wrong Answer

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

res_count = 0

for i in range(0, N-1):
    d_ave = sum([d_list[i], d_list[i+1]]) / 2
    ARC_list = [d for d in d_list if d_ave <= d]
    ABC_list = [d for d in d_list if d_ave > d]
    
    if( len(ARC_list) == len(ARC_list) ):
        for K in range(d_list[i], d_list[i+1]):
            ARC = 0
            ABC = 0
            for d in d_list:
                if( d >= K ):
                    ARC += 1
                else:
                    ABC += 1
            if( ARC == ABC ):
                res_count += 1

print(res_count)

Submission status: Wrong Answer

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

res_count = 0

for i in range(0, N-1):
    d_ave = sum([d_list[i], d_list[i+1]]) / 2
    ARC_list = [d for d in d_list if d_ave <= d]
    ABC_list = [d for d in d_list if d_ave > d]
    print('{} {} {}'.format(d_ave, ARC_list, ABC_list))
    
    if( len(ARC_list) == len(ARC_list) ):
        for K in range(d_list[i], d_list[i+1]):
            ARC = 0
            ABC = 0
            for d in d_list:
                if( d >= K ):
                    ARC += 1
                else:
                    ABC += 1
            if( ARC == ABC ):
                res_count += 1

print(res_count)

Submission status: Wrong Answer

Solution code:
n = int(input())
d_lis = [int(d) for d in input().split()]
ans = 0
li = [0] * (max(d_lis)+1)
for i in range(1,max(d_lis)+1):
    li[i] = d_lis.count(i)
for i in range(1,len(li)-1):
    li[i] += li[i-1]
for num in li:
    if num == n // 2:
        ans += 1
print(ans)

Submission status: Wrong Answer

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

cnt = 0

sd = sorted(d)

var1 = int((min(sd) + max(sd)) / 2)
var2 = var1-1

def func(k):
    abc = 0
    arc = 0
    for i in sd:
        if k <= i:
            arc+=1
        else:
            abc+=1
    return arc==abc
    
while func(var1):
    cnt+=1
    var1+=1

while func(var2):
    cnt+=1
    var2-=1

print(cnt)