Problem:


Score : 200 points

Problem Statement

There are N + 1 squares arranged in a row, numbered 0, 1, ..., N from left to right.

Initially, you are in Square X.
You can freely travel between adjacent squares. Your goal is to reach Square 0 or Square N.
However, for each i = 1, 2, ..., M, there is a toll gate in Square A_i, and traveling to Square A_i incurs a cost of 1.
It is guaranteed that there is no toll gate in Square 0, Square X and Square N.

Find the minimum cost incurred before reaching the goal.

Constraints

1 \leq N \leq 100

1 \leq M \leq 100

1 \leq X \leq N - 1

1 \leq A_1 < A_2 < ... < A_M \leq N

A_i \neq X

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N M X
A_1 A_2 ... A_M

Output

Print the minimum cost incurred before reaching the goal.

Sample Input 1

5 3 3
1 2 4

Sample Output 1

1

The optimal solution is as follows:

First, travel from Square 3 to Square 4. Here, there is a toll gate in Square 4, so the cost of 1 is incurred.

Then, travel from Square 4 to Square 5. This time, no cost is incurred.

Now, we are in Square 5 and we have reached the goal.

In this case, the total cost incurred is 1.

Sample Input 2

7 3 2
4 5 6

Sample Output 2

0

We may be able to reach the goal at no cost.

Sample Input 3

10 7 5
1 2 3 4 6 8 9

Sample Output 3

3



Sample input:
5 3 3
1 2 4


Sample output:
1

Submission status: Wrong Answer

Solution code:
N, M, X = map(int, input().split())
A = list(map(int,input().split()))
for i in range(M):
  if A[i] < X < A[i+1]:
    print(min(i+1, M-i-1))

Submission status: Wrong Answer

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

for i in range(M):
  if A[i] < X:
    continue
  elif A[i] > X and i > (N-1)//2:
    print(len(A)-i)
    break
  elif A[0] > X:
    print(0)
    break
  else:
    print(i-1)
    break

Submission status: Wrong Answer

Solution code:
N,M,X=map(int,input().split())
A=list(map(int,input().split()))
cnt=0
if X<N-X:
    for i in range(X):
        if i in A:
            cnt+=1
else:
    for i in range(X,N):
        if i in A:
            cnt+=1
print(cnt)

Submission status: Wrong Answer

Solution code:
N,M,X = map(int,input().split(" "))
A = [int(i) for i in input().split(" ")]
low = [0]*(N+1)

for i in A:
    low[i]=1

count = 0
if X<(N/2):
    while(X!=0):
        count+=low[X]
        X-=1
else:
    while(X!=N):
        count+=low[X]
        X+=1
print(count)

Submission status: Wrong Answer

Solution code:
a,b,c = map(int,input().split())
n_list = list(map(int,input().split()))
ans = 0
for i in n_list:
  if i >=c and i <=a:
    ans+=1
    
print(ans)

Submission status: Wrong Answer

Solution code:
from bisect import bisect_left
N, M, X = map(int,input().split())
A = list(map(int,input().split()))
index = bisect_left(A, X)
ans = min(index, M - index)

Submission status: Wrong Answer

Solution code:
n,m,x = map(int,input().split())
a_inputs = [int(i)-1 for i in input().split()]

map_list = [0 for i in range(n+1)]

for i in range(n+1):
    if i in a_inputs:
        map_list[i]=1

ans=0

if n-x<x:
    for i in range(x-1,n):
        ans+=map_list[i]
if n-x>x:
    for i in range(x-1,-1,-1):
        ans+=map_list[i]
else:
    ans1=0
    ans2=0
    for i in range(x-1,n):
        ans1+=map_list[i]
    for i in range(x-1,-1,-1):
        ans2+=map_list[i]
    ans=min(ans1,ans2)
print(ans)

Submission status: Wrong Answer

Solution code:
n,m,x = map(int,input().split())
a = list(map(int,input().split()))
count = 0
for i in range(len(a)):
  if x < a[i]:
    count += 1
print(count)

Submission status: Wrong Answer

Solution code:
n,m,x = map(int,input().split())
a = list(map(int,input().split()))
count = 0
for i in range(m):
  if x < a[i]:
    count += 1
print(count)

Submission status: Wrong Answer

Solution code:
n, m, x = map(int, input().split())
a=list(map(int, input().split()))
cost=0
for i in range(m):
  if a[i]>x:
    cost+=1
print(cost)

Submission status: Wrong Answer

Solution code:
n, m, x = map(int, input().split())
a=list(map(int, input().split()))
cost=0
for i in range(m):
  if a[i]>x:
    cost+1
print(cost)

Submission status: Wrong Answer

Solution code:
n,m,x=map(int,input().split())
aa=list(map(int,input().split()))

cost=0
for i in range(x,n+1):
  if i in aa:
    cost+=1
print(cost)

Submission status: Wrong Answer

Solution code:
n,m,x=map(int,input().split())
a=list(map(int,input().split()))
l=[set(a)&set(list(range(1,x)))]
r=[set(a)&set(list(range(x+1,n)))]
print(min(len(l),len(r)))

Submission status: Wrong Answer

Solution code:
n, m, x = map(int, input().split())
a=list(map(int,input().split()))

if a[-1] < x :
  print('0')
else:
  print(min(x-1, a[-1]-x))

Submission status: Wrong Answer

Solution code:
N, M, X = map(int, input().split())
A = list(map(int, input().split()))
S = sum(s < X for s in A)
print(min(S, N-S))

Submission status: Wrong Answer

Solution code:
N,M,X=map(int, input().split())
A=list(map(int, input().split()))
count=0
for i in range(M):
  if N>A[i]>X:
    count+=1
    
print(count)

Submission status: Wrong Answer

Solution code:
n,m,x = map(int,input().split())
a = [int(i) for i in input().split()]

ans =0
for i in range(x+1,n+1):
  if x+1 in a:
    ans +=1
  
  
print(ans)

Submission status: Wrong Answer

Solution code:
n, m, x = map(int, input().split())
count1 = x
count2 = n - x
for a in map(int, input().split()):
  if a < x:
    count1 += 1
  else:
    count2 += 1

print(min(count1, count2))

Submission status: Wrong Answer

Solution code:
N,M,X=map(int,input().split())
A=list(map(int,input().split()))
money=[0]*N
for i in A:
    money[i-1]+=1
print(min(sum(money[:X+1]), sum(money[X:])))

Submission status: Wrong Answer

Solution code:
n,m,x=map(int,input().split())
a=list(map(int,input().split()))
r=[]
for y in range(n+1):
    if y in a:r.append(1)
    else:r.append(0)
print(min(sum(r[:x-1]),sum(r[x-1:])))

Submission status: Wrong Answer

Solution code:
n,m,x=map(int,input().split())
a=list(map(int,input().split()))
if x==2 or x==n-1:print(0)
else:print(min(len(a[:x-1]),len(a[x-1:])))

Submission status: Wrong Answer

Solution code:
n,m,x=map(int,input().split())
*a,=map(int,input().split())
cst_0=0
cst_n=0
for i in range(1,x):
	if (x-i) in a:
		cst_0 += 1
for i in range(x+1,n):
	if i in a:
		cst_n += 1
ans=min(cst_0,cst_n)

Submission status: Wrong Answer

Solution code:
n,m,x=map(int,input().split())
*a,=map(int,input().split())
cst_0=0
cst_n=0
for i in range(1,x-1):
	if (x-i) in a:
		cst_0 += 1
for i in range(x+1,n):
	if i in a:
		cst_n += 1
ans=min(cst_0,cst_n)
print(ans)

Submission status: Wrong Answer

Solution code:
import bisect

n,m,x = map(int,input().split())
l = list(map(int,input().split()))
index = bisect.bisect_left(l,x)
print(min(index,n-index))

Submission status: Wrong Answer

Solution code:
n,m,x = map(int,input().split())
a = list(map(int,input().split()))
c = sum(int(b)<x for b in a )
d = sum(a) - c
print(min(c,d))

Submission status: Wrong Answer

Solution code:
n, m, x = (int(i) for i in input().split())
a = [0] * (n+1)

for i in input().split():
    k = int(i)
    a[k] = 1

ans = 1000
tmp = 0
for i in a[x: 0: -1]:
    tmp += a[i]

ans = min(tmp, ans)

tmp = 0
for i in a[x:n+1]:
    tmp += a[i]

ans = min(tmp, ans)

print(ans)

Submission status: Wrong Answer

Solution code:
import bisect

n,m,x=map(int,input().split())
a =list(map(int,input().split()))

l=bisect.bisect_left(a,x)
r=m-l
print(min(x+l,n-x+r))

Submission status: Wrong Answer

Solution code:
N, M, X=map(int, input().split())
sum=sum(int(i)<X for i in input().split())
print(min(sum, N-sum))

Submission status: Wrong Answer

Solution code:
N,M,X=map(int, input().split())
a=list(map(int, input().split()))
x=len(set(range(X,N+1)) & set(a))
y=len(set(reversed(range(X))) & set(a))
print(x)
print(y)

Submission status: Wrong Answer

Solution code:
N, M, X = map(int, input().split())
A = list(map(int, input().split()))
cnt1 = 0
cnt2 = 0
i = 0
j = 0
while i <= N:
  if i in A:
    cnt1 += 1
  i += 1
while j >= 0:
  if j in A:
    cnt2 += 1
  j -= 1
print(min(cnt1, cnt2))

Submission status: Wrong Answer

Solution code:
N,M,X =(map(int,input().split()))
A =list(map(int,input().split()))
min(sum(a>X for a in A),sum(a<X for a in A))

Submission status: Wrong Answer

Solution code:
a,b,c = (map(int, input().split())) 
n = list(map(int, input().split())) 
charge=0
for i in range(b):
  if c<n[i]<a:
    charge+=1
print(charge)

Submission status: Wrong Answer

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

#Nがゴール　Xがスタート　Mが料金所の数。
ans = 0


for i in range(X,N+1):
    if i in A:
        ans = ans + 1

print(ans)

Submission status: Wrong Answer

Solution code:
N,M,X = map(int,input().split())
A = list(map(int,input().split()))
count = 0
B = []
if N == X:
  print(0)
else:
  for x in range(X,N+1):
    if x in A:
      count += 1
  B.append(count)
  count = 0
  for x in range(0,X+1,-1):
    if x in A:
      count += 1
  B.append(count)
  print(min(B))

Submission status: Wrong Answer

Solution code:
N,M,X = map(int,input().split())
A = list(map(int,input().split()))
count = 0
if N == X:
  print(0)
else:
  for x in range(X,N+1):
    if x in A:
      count += 1
  print(count)

Submission status: Wrong Answer

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

ans1 = 0
for i in range(X + 1,N):
  if i in A[X - 1:N - 1]:
    ans1 += 1

ans2 = 0
for i in reversed(range(X)):
  if i in A[:X]:
    ans2 += 1

print(min(ans1,ans2))

Submission status: Wrong Answer

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

ans = 0
for i in range(X + 1,N):
  if i in A[X - 1:N - 1]:
    ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
N, M, X = map(int, input().split())
A = [int(i) for i in input().split()]
ans = 0
for a in A:
    if a > M:
        break
    ans += 1
print(min(ans, len(A) - ans))

Submission status: Wrong Answer

Solution code:
n,m,x = map(int,input().split())
A = list(map(int,input().split()))
A.append(n)
A.append(x)
A = sorted(A)
if abs(A.index(n) - A.index(x)) < abs(A.index(x) - 0):
  if x == n:
    print(0)
  else:
    print(abs(A.index(n) - A.index(x)) - 1 )
else:
  if x == A[0]:
    print(0)
  else:
    print(abs(A.index(x) - 0) - 1 )

Submission status: Wrong Answer

Solution code:
n,m,x = map(int,input().split())
A = list(map(int,input().split()))
A.append(n)
A.append(x)
A = sorted(A)
if abs(n - x) < abs(x - A[0]):
  if x == n:
    print(0)
  else:
    print(abs(n - x) - 1 )
else:
  if x == A[0]:
    print(0)
  else:
    print(abs(x - A[0]) - 1 )

Submission status: Wrong Answer

Solution code:
N,M,X = map(int,input().split())
A = list(map(int,input().split()))
for i,x in enumerate(A):
  if x > X:
    t = i
    break

print(t,M-t)

Submission status: Wrong Answer

Solution code:
import bisect
N, M, X = map(int, input().split())
lst = list(map(int, input().split()))

a = bisect.bisect_left(lst, M)
print(min(M-a, a))

Submission status: Wrong Answer

Solution code:
import bisect
N, M, X = map(int, input().split())
lst = list(map(int, input().split()))

a = bisect.bisect_left(lst, M)
print(min(N-a, a))

Submission status: Wrong Answer

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

A = [int(i) for i in input().split()]
couA = 0
couB  =0
for i in range(m,n):
    if A.count(i):
        couA +=1
for j in range(m,0,-1):
    if A.count(j):
        couB +=1
print(min(couA,couB))

Submission status: Wrong Answer

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

aa = list(map(int,input().split()))
a = [0]*(n+1)
for ai in aa:
  a[ai]=1
  
print(min(sum(a[:x-1]),sum(a[x:])))

Submission status: Wrong Answer

Solution code:
n,m,x = map(int,input().split())
aa = list(map(int,input().split()))
  
print(min(sum(aa[:x-2]),sum(aa[x-1:])))

Submission status: Wrong Answer

Solution code:
from bisect import bisect_left
N,M,X = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
b = bisect_left(A,X)
if b==0:
  print(0)
  exit()
print(min(b-1,M-b))

Submission status: Wrong Answer

Solution code:
N, M, X = map(int, input().split())
A = list(map(int, input().split()))
res = [0]*N
for a in A:
    res[a] = 1
print(min(sum(res[0:X-1]), sum(res[X:])))

Submission status: Wrong Answer

Solution code:
N,M,X = map(int, input().split())

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

A.append(X)
A.sort()

X_i = int(A.index(X)) -1 

t = len(A)

diff_b = t - X_i

if diff_b < 0 or X_i < 0:
  print(0)
elif diff_b < X_i:
  print(diff_b -1)
else:
  print(X_i)

Submission status: Wrong Answer

Solution code:
N,M,X = map(int, input().split())

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

A.append(X)
A.sort()

X_i = int(A.index(X)) -1 

t = len(A)

diff_b = t - X_i

if diff_b < 0 or X_i < 0:
  print(0)
elif diff_b < X_i:
  print(diff_b)
else:
  print(X_i)

Submission status: Wrong Answer

Solution code:
N,M,X = map(int, input().split())

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

# for i in range(M):
#   A.append(input())

A.append(X)
A.sort()

X_i = int(A.index(X)) -1 

t = len(A)

diff_b = t - X_i

if diff_b < 0 or X_i < 0:
  print(0)

elif diff_b < X_i:
  print(diff_b)
else:
  print(X_i)

Submission status: Wrong Answer

Solution code:
n, m, x = map(int, input().split())
a = list(map(int, input().split()))
cnt = 0
tmp = 0
for i in range(m):
    if a[i] < x-1:
        cnt += 1
    else:
        tmp += 1
print(min(cnt,tmp))

Submission status: Wrong Answer

Solution code:
n,m,x = map(int,input().split())
a = list(map(int,input().split()))

a.append(x)
a = sorted(a)

if len(a[:a.index(x)]) >= len(a[-(a.index(x)+1):]):
  print(len(a[-(a.index(x)+1):]))
else:
  print(len(a[:a.index(x)]))

Submission status: Wrong Answer

Solution code:
def main():
  N, M, X = map(int, input().split())
  a = [0] + list(map(int, input().split())) + [N]
  
  i = 0
  while a[i] < N:
    i += 1
  print(min(i-1, M + 1 - i))

if __name__ == "__main__":
  main()

Submission status: Wrong Answer

Solution code:
n,m,x=map(int,input().split())
a=list(map(int,input().split()))
print(a)
print(min((len([i for i in a if i<x])),(len([i for i in a if i>x]))))

Submission status: Wrong Answer

Solution code:
n,m,x=map(int,input().split())
b=[0]*(n+1)
A=list(map(int,input().split()))
for a in A:
  b[a]=1
c=0
for i in range(x):
  c+=b[i]
print(n-c if c>=n-c else c)

Submission status: Wrong Answer

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

cnt = 0
for i in range(M-1,N):
  if i in A:
    cnt += 1
print (min(cnt, M-cnt))

Submission status: Wrong Answer

Solution code:
n,m,x=map(int,input().split())
As=list(map(int,input().split()))

way=[]
for i in range(n):
  way.append(i)
  
ans1,ans2=0,0
for i in range(m,n,1):
  if i in As:
    ans1+=1
for i in range(m,0,-1):
  if i in As:
    ans2+=1
print(min(ans1,ans2))

Submission status: Wrong Answer

Solution code:
n,m,x = map(int,input().split())
a = list(map(int,input().split()))
c = 0
d = 0
for i in range(1,x-1):
    if i in a:
        c += 1
for i in range(x+1,n-1):
    if i in a:
        d += 1
print(min(c,d))

Submission status: Wrong Answer

Solution code:
n,m,x = map(int,input().split())
a = list(map(int,input().split()))
c = 0
d = 0
for i in range(x-1):
    if i in a:
        c += 1
for i in range(x+1,n):
    if i in a:
        d += 1
print(min(c,d))

Submission status: Wrong Answer

Solution code:
n, m, x = map(int, input().split())
l = list(map(int, input().split()))
left = 0
right = 0
i = 0
while i < x:
    if i in l:
        left += 1
    i += 1
j = n-1
while j > x+1:
    if j in l:
        right += 1
    j -= 1

print(min(left, right))

Submission status: Wrong Answer

Solution code:
n, m, x = map(int, input().split())
l = list(map(int, input().split()))
left = 0
right = 0
i = 0
while i < x:
    if i in l:
        left += 1
    i += 1
j = n-1
while j > x+1:
    if j in l:
        right += 1
    j -= 1

print(max(left, right))

Submission status: Wrong Answer

Solution code:
n, m, x = map(int, input().split())
a = list(map(int, input().split()))
for i,j in enumerate(a):
  if j > x:
    cnt = i
    break
print(min(cnt, m-cnt+1))

Submission status: Wrong Answer

Solution code:
n, m, x = map(int, input().split())
a = list(map(int, input().split()))
for i,j in enumerate(a):
  if j > x:
    cnt = i
    break
print(min(cnt, x-cnt))

Submission status: Wrong Answer

Solution code:
n, m, x = map(int, input().split())
a = list(map(int, input().split()))
print(min(sum(a[:x+1]), sum(a[x+1:])))

Submission status: Wrong Answer

Solution code:
n, m, x = map(int, input().split())
a = list(map(int, input().split()))
print(min(sum(a[:x]), sum(a[x:])))

Submission status: Wrong Answer

Solution code:
n, m, x = map(int, input().split())
a = list(map(int, input().split()))
print(min(sum(a[:m]), sum(a[m:])))

Submission status: Wrong Answer

Solution code:
n, m, x = map(int, input().split())
a = list(map(int, input().split()))
print(max(sum(a[:m]), sum(a[m:])))

Submission status: Wrong Answer

Solution code:
N,M,X=map(int,input().split())
A=list(map(int,input().split()))
N_cost=len(list(filter(lambda x:x >X, A)))
Z_cost=len(list(filter(lambda x:x <X, A)))
print(N_cost)

Submission status: Wrong Answer

Solution code:
N,M,X=map(int,input().split())
A=list(map(int,input().split()))
N_cost=len([i>X for i in A])
Z_cost=len([i<X for i in A])
print(min(N_cost,Z_cost))

Submission status: Wrong Answer

Solution code:
n,m,x=map(int,input().split())
s=sum(int(i)<x for i in input().split())
print(min(s,s-m))

Submission status: Wrong Answer

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

posi=0
for i in range(M-1):
  if (A[i]<X)and(X<A[i+1]):
    posi=i
if posi==0:
  print(0)
else:
  print(min(len(A[:posi]),len(A[posi-1:])))

Submission status: Wrong Answer

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

posi=0
for i in range(M-1):
  if (A[i]<X)and(X<A[i+1]):
    posi=i
if posi==0:
  print(0)
else:
  print(min(len(A[:posi]),len(A[posi:])))

Submission status: Wrong Answer

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

posi=0
for i in range(len(A)-1):
  if (A[i]<X)and(X<A[i+1]):
    posi=i
if posi==0:
  print(0)
else:
  print(min(len(A[:posi]),len(A[posi:])))

Submission status: Wrong Answer

Solution code:
n,m,x=map(int, input().split())
a=map(int, input().split())

left=0
right=0

for i in a:
  if x > int(i):
    left += 1
  elif x < int(i):
    righit =+ 1
print(min(left,right))

Submission status: Wrong Answer

Solution code:
n,m,x = map(int,input().split())
a = list(map(int,input().split()))

cost = 0
for i in range(0,x-1):
    if i in a:
        cost += 1
cost2 = 0
for i in range(x,n+1):
    if i in a:
        cost2 +=1
print(min(cost,cost2))

Submission status: Wrong Answer

Solution code:
n,m,x = map(int,input().split())
a = list(map(int,input().split()))

cost = 0
for i in range(0,x-1):
    if i in a:
        cost += 1
cost2 = 0
for i in range(x,n):
    if i in a:
        cost2 +=1
print(min(cost,cost2))

Submission status: Wrong Answer

Solution code:
n,m,x = map(int,input().split())
a = list(map(int,input().split()))

cost = 0
for i in range(0,x-1):
    if i in a:
        cost += 1
print(cost)

Submission status: Wrong Answer

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

li = [1 if i in li else 0 for i in range(1, n+1)]

print(min(sum(li[:x]), sum(li[x+1:])))

Submission status: Wrong Answer

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

print(min(sum(li[:x]), sum(li[x+1:])))

Submission status: Wrong Answer

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


print(min(len(li[:x]), len(li[x+1:])))

Submission status: Wrong Answer

Solution code:
n, m, x = map(int, input().split())
if m > x:
  m, x = x, m

c = [i for i in (map(int, input().split())) if m < i < x]
print(sum(c))

Submission status: Wrong Answer

Solution code:
n, m, x = map(int, input().split())
c = [i for i in (map(int, input().split())) if m < i < x]
print(sum(c))

Submission status: Wrong Answer

Solution code:
n, m, x = map(int, input().split())
c = [0] * n
for i in (map(int, input().split())):
  c[i - 1] = 1
if m > x:
  m, x = x , m
print(sum(c[m - 1:x]))

Submission status: Wrong Answer

Solution code:
n, m, x = map(int, input().split())
c = [0] * n
for i in (map(int, input().split())):
  c[i - 1] = 1
if m > x:
  m, x = x , m
print(sum(c[m:x]))

Submission status: Wrong Answer

Solution code:
a, b, c = map(int, input().split())
d = list(map(int, input().split()))
e = 0
f = 0
for i in range(c, a+1):
    if (i+1) in d:
        e += 1
for i in range(c, -1, -1):
    if (i + 1) in d:
        f += 1
print(min(e, f))

Submission status: Wrong Answer

Solution code:
N, M, X = map(int, input().split())
A = [int(i) for i in input().split()]

ans = []
xx = X
num = 0
for i in range(1, 101):
    X += 1
    if A.count(X) == 1:
        num += 1

ans.append(num)
num = 0
for i in range(1, 101):
    xx -= 1
    if A.count(xx) == 1:
        num += 1

ans.append(num)
ans.sort()
print(ans[0])
print(ans)

Submission status: Wrong Answer

Solution code:
N,M,X = map(int, input().split())
L = [int(i) for i in input().split()]

left = 0
right = 0

for i in range(len(L)):
    if i < X:
        left += 1
    else:
        right += 1

print(min(left, right))

Submission status: Wrong Answer

Solution code:
N, M, X = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]

cell = [0] * (N+1)

for a in A:
    cell[a] = 1
print(cell)
print(min(sum(cell[:X]), sum(cell[X:])))

Submission status: Wrong Answer

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


def solve(N: int, M: int, X: int, A: "List[int]"):
    L = [0] * (N+1)
    for a in A:
        L[a] = 1
    print(min(sum(L[0:X-1]),sum(L[X+1:])))

    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
    M = int(next(tokens))  # type: int
    X = int(next(tokens))  # type: int
    A = [ int(next(tokens)) for _ in range(M) ]  # type: "List[int]"
    solve(N, M, X, A)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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


def solve(N: int, M: int, X: int, A: "List[int]"):
    L = [0] * N
    for a in A:
        L[a-1] = 1
    print(min(sum(L[0:X-2]),sum(L[X:])))

    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
    M = int(next(tokens))  # type: int
    X = int(next(tokens))  # type: int
    A = [ int(next(tokens)) for _ in range(M) ]  # type: "List[int]"
    solve(N, M, X, A)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
_,M,X = list(map(int,input().split()))
a = list(map(int,input().split()))

'''
for i,c in enumerate(a):
    if X < c:
        print(min(i,M-i))
        break
'''
import bisect
i = bisect.bisect_left(a,X)
print(i,M-i)

Submission status: Wrong Answer

Solution code:
_,M,X = list(map(int,input().split()))
a = list(map(int,input().split()))
for i,c in enumerate(a):
    print(i,c,X)
    if X < c:
        print(min(i,M-i))
        break

Submission status: Wrong Answer

Solution code:
n,m,x=map(int,input().split())
a=map(int,input().split())
print(min(len([i for i in a if x<i]),len([i for i in a if x>i])))

Submission status: Wrong Answer

Solution code:
box_l, _, start = map(int, input().split())
arr = [0]*(box_l+1)
cost_arr = list(map(int, input().split()))
for num in cost_arr:
  arr[num] = 1
print(sum(min(arr[:start+1],arr[start+1:])))

Submission status: Wrong Answer

Solution code:
box_l, _, start = map(int, input().split())
arr = [0]*(box_l+1)
cost_arr = list(map(int, input().split()))
for num in cost_arr:
  arr[num] = 1
print(sum(min(arr[start:],arr[:start])))

Submission status: Wrong Answer

Solution code:
box_l, _, start = map(int, input().split())
arr = [0]*(box_l+1)
cost_arr = list(map(int, input().split()))
for num in cost_arr:
  arr[num-1] = 1
print(sum(min(arr[start:],arr[:start])))

Submission status: Wrong Answer

Solution code:
box_l, _, start = map(int, input().split())
arr = [0]*box_l
cost_arr = list(map(int, input().split()))
for num in cost_arr:
  arr[num-1] = 1
print(sum(min(arr[start:],arr[:start])))

Submission status: Wrong Answer

Solution code:
n,m,x=map(int,input().split())
a=list(map(int,input().split()))

for i in range(m):
    if a[i]>x:
        p=i
        break
if x<a[0]:
    p=0
print(p)
print(min(p,m-p))

Submission status: Wrong Answer

Solution code:
n,m,x=map(int,input().split())
a=list(map(int,input().split()))

for i in range(m):
    if a[i]<x:
        p=i+1
        break
if x<a[0]:
    p=0
print(min(p,m-p))

Submission status: Wrong Answer

Solution code:
n,m,x=map(int,input().split())
a=list(map(int,input().split()))

for i in range(m):
    if a[i]<=x:
        p=i+1
        break
if x<a[0] or a[-1]<x:
    p=0
print(min(p,m-p))

Submission status: Wrong Answer

Solution code:
n,m,x = map(int,input().split())
li = list(map(int,input().split()))
if x < li[0] or x > li[m-1] :
    print(0)
else :
    for i in range(m-1) :
        print(min(i+1,m-i-1))

Submission status: Wrong Answer

Solution code:
N, M, X = map(int, input().split())
A = list(map(int, input().split()))
cost1 = 0
cost2 = 0
for i in range(1, N-X+1):
    if X + i in A:
        cost1 += 1

for i in reversed(range(X-1)):
    if i in A:
        cost2 += 1

print(min(cost1, cost2))

Submission status: Wrong Answer

Solution code:
N, M, X = map(int, input().split())
A = [int(i) for i in input().split()]

for i, v in enumerate(A):
  if v >= X:
    tmp = i
    break
if tmp >= M / 2:
  res = M - tmp + 1
else:
  res = tmp + 1
print(tmp)

Submission status: Wrong Answer

Solution code:
input_data = input().replace("\n", " ").split(" ")

n, m, x = int(input_data[0]), int(input_data[1]), int(input_data[2])


def problemB(n, m, x):
    masu_list = [0] * (n+1)
    adder = input_data[3:]

    for i in adder:
        masu_list[int(i)] = 1
    front = sum(masu_list[:x])
    back = sum(masu_list[x+1:])

    if front <= back:
        return print(front)

    else:
        return print(back)


problemB(n, m, x)

Submission status: Wrong Answer

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

c1 = 0
for i in range(X+1, N):
    if i in A:
        c1 += 1
c2 = 0
for i in range(X-1, 1, -1):
    if i in A:
        c2 += 1

print(c1 if c1 < c2 else c2)

Submission status: Wrong Answer

Solution code:
N, M, X = map(int, input().split())
A = list(map(int, input().split()))
cnt = 0
for i in range(M):
    if A[i] > X:
        cnt += 1
print(cnt)

Submission status: Wrong Answer

Solution code:
#094 B
N,M,X= map(int,input().split())
A = [int(j) for j in input().split()]
left =0
right = 0

for i in range(1,X-1):
    if i in A:
        left+=1
for i in range(X+1,N):
    if i in A:
        right+=1
print(min(left,right))

Submission status: Wrong Answer

Solution code:
#094
N,M,X= map(int,input().split())
A = [int(j) for j in input().split()]
left =0
right = 0

for i in range(1,X-1):
    if i in A:
        left+=1
for i in range(X+1,N+1):
    if i in A:
        right+=1
print(min(left,right))

Submission status: Wrong Answer

Solution code:
N, M, X = map(int, input().split())

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

l = A[:X]
r = A[X+1:]

ans = []

ans.append(len(l)-1)
ans.append(len(r)-1)

print(min(ans))

Submission status: Wrong Answer

Solution code:
N, M, X = map(int, input().split())
A = [int(i) for i in input().split()]
n_1 = sum(N > x for x in A)
n_2 = sum((N-x)*(X-x) < 0 for x in A)
#n_1 = sum([1 for x in A if x < X])
#n_2 = sum([1 for x in A if (N-x)*(X-x) < 0])
ans = min(n_1, n_2)
print(ans)

Submission status: Wrong Answer

Solution code:
n,m,x=map(int,input().split())
a=list(map(int,input().split()))
i=0
while(a[i]<x):
    i+=1
if(i>len(a)/2):
    print(len(a)//2)
else:
    print(i)

Submission status: Wrong Answer

Solution code:
n,m,x=map(int,input().split())
l=[0for i in range(n+1)]
for i in map(int,input().split()):
  l[i]=1
for i in range(1,n+1):
  l[i]+=l[i-1]
print(min(l[x],l[n]))

Submission status: Wrong Answer

Solution code:
N, M, X = map(int,input().split())
a = list(map(int,input().split()))
count = 0
if N > X:
  for i in range(X,100,1):
    if a.count(i) == 1:
      count += 1
    if i == N:
      print(count)
      break
elif N < X:
  for i in range(X,100,-1):
    if a.count(i) == 1:
      count += 1
    if i == N or i == 0:
      print(count)
      break
else:
  print("0")

Submission status: Wrong Answer

Solution code:
N, M, X = map(int,input().split())
a = list(map(int,input().split()))
count = 0
if N > X:
  for i in range(X,100,1):
    if a.count(i) == 1:
      count += 1
    if i == N:
      print(count)
      break
elif N < X:
  for i in range(X,100,-1):
    if a.count(i) == 1:
      count += 1
    if i == N:
      print(count)
      break
else:
  print("0")

Submission status: Wrong Answer

Solution code:
n,m,x=map(int,input().split())
a=list(map(int,input().split()))
c1,c2=0,0
for i in range(m):
  if i < x:
    c1+=1
  else:
    c2+=1
print(min(c1,c2))

Submission status: Wrong Answer

Solution code:
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N, M, X = map(int, input().split())
a = list(map(int, input().split()))
ans = 0
for i in reversed(range(X)):
    if i in a:
        ans += 1
print(ans)

Submission status: Wrong Answer

Solution code:
import bisect
N, M, X = list(map(int, input().split()))
A = list(map(int, input().split()))
A.sort()

index = bisect.bisect_right(A, X)
print(max(0, min(index - 1, len(A) - index)))

Submission status: Wrong Answer

Solution code:
N,M,X=map(int,input().split())
A_list=list(map(int,input().split()))

c=0
for i in range(M-1):
    if(A_list[i]<X<A_list[i+1]):
        c=i
        break
print(min(c,N-c))

Submission status: Wrong Answer

Solution code:
n,m,x = map(int,input().split())
y = list(map(int,input().split()))
s = 0
cs = 0
t = 0
for i in y:
    if x > i:
        s+=1
    elif x == i:
        cs=0
    else:
        t+=1
if t>s and cs!=0:
    print(s)
elif t<=s and cs!=0:
    print(t)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
N,M,X = map(int,input().split()) #整数の入力
a = list(map(int,input().split()))
#検問所の入力
b=[]
c=[]
for i in range(X+1,N): #X+1からNの範囲の整数について 
  if i in a: #ある整数が検問所の整数として存在する
    b.append(1)
for i in range(1,X): #1からX-1の範囲の整数について
  if i in a: #ある整数が検問所の整数として存在する
    c.append(1)
print(sum(c))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
N,M,X = map(int,input().split()) #整数の入力
a = [int(i) for i in range(M)] #検問所の入力
b=[]
c=[]
for i in range(X+1,N): #XからNの範囲の整数について 
  if i in a is True: #ある整数が検問所の整数として存在する
    b.append(1)
for i in range(1,X): #1からX-1の範囲の整数について
  if i in a is True: #ある整数が検問所の整数として存在する
    c.append(1)
print(min(sum(b),sum(c)))