Problem:


Score : 300 points

Problem Statement

Given are an integer X and an integer sequence of length N: p_1, \ldots, p_N.

Among the integers not contained in the sequence p_1, \ldots, p_N (not necessarily positive), find the integer nearest to X, that is, find the integer whose absolute difference with X is the minimum. If there are multiple such integers, report the smallest such integer.

Constraints

1 \leq X \leq 100

0 \leq N \leq 100

1 \leq p_i \leq 100

p_1, \ldots, p_N are all distinct.

All values in input are integers.

Input

Input is given from Standard Input in the following format:

X N
p_1 ... p_N

Output

Print the answer.

Sample Input 1

6 5
4 7 10 6 5

Sample Output 1

8

Among the integers not contained in the sequence 4, 7, 10, 6, 5, the one nearest to 6 is 8.

Sample Input 2

10 5
4 7 10 6 5

Sample Output 2

9

Among the integers not contained in the sequence 4, 7, 10, 6, 5, the ones nearest to 10 are 9 and 11. We should print the smaller one, 9.

Sample Input 3

100 0

Sample Output 3

100

When N = 0, the second line in the input will be empty. Also, as seen here, X itself can be the answer.



Sample input:
6 5
4 7 10 6 5


Sample output:
8

Submission status: Wrong Answer

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


P_n = [i for i in range(1,110,1) if i not in P]
print(P_n)
abs_value = [abs(X-P_n[j]) for j in range(len(P_n))]


min_abs = min(abs_value)
for k in range(len(abs_value)):
    if abs_value[k] == min_abs:
        print(P_n[k])
        break

Submission status: Wrong Answer

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


P_n = [i for i in range(1,101+N,1) if i not in P]
abs_value = [abs(X-P_n[j]) for j in range(len(P_n))]


min_abs = min(abs_value)
for k in range(len(abs_value)):
    if abs_value[k] == min_abs:
        print(P_n[k])
        break

Submission status: Wrong Answer

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

P_n = [i for i in range(0,101,1) if i not in P]
abs_value = [abs(X-P_n[j]) for j in range(len(P_n))]

import sys

min_abs = min(abs_value)
for k in range(len(abs_value)):
    if abs_value[k] == min_abs:
        print(P_n[k])
        sys.exit()

Submission status: Wrong Answer

Solution code:
x, n = map(int, input().split())
if n == 0:
    print(x)
    
P = set(map(int, input().split()))

d_min = 1000
ans = 1000
for num in range(-1, 102):
    if num in P:
        continue
    
    d = abs(x-num)
    if d < d_min:
        d_min = d
        ans = num

print(ans)

Submission status: Wrong Answer

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

P_n = [i for i in range(1,102,1) if i not in P]
abs_value = [abs(X-P_n[j]) for j in range(len(P_n))]


min_abs = min(abs_value)
for k in range(len(P_n)):
    if abs_value[k] == min_abs:
        print(P_n[k])
        break

Submission status: Wrong Answer

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

if N == 0:
  print(X)
else:
  P = set(map(int, input().split()))
  for i in range((N + 1) // 2):
    if X - i not in P:
      print(X - i)
      break
    elif X + i not in P:
      print(X + i)
      break

Submission status: Wrong Answer

Solution code:
X, N = map(int, input().split())
try:
  P = set(map(int, input().split()))
except:
  P = set()
  
for i in range((N + 1) // 2):
  if X - i not in P:
    print(X - i)
    break
  elif X + i not in P:
    print(X + i)
    break

Submission status: Wrong Answer

Solution code:
a,b=map(int,input().split())
c=list(map(int,input().split()))
d=list(range(-1,101))

n=list(set(c)^set(d))
m=[]
for i in n:
    m.append(abs(i-a))

print(n[m.index(min(m))])

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10000000)

x,n = map(int,input().split())

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


if n == 0:print(x);exit()

l=[0] * 101

for i in p:
    l[i] =1

diff=1000
ans=0
for i in range(1,101):
    if l[i] == 0 and diff > abs(x-i):
        diff= abs(x-i)
        ans=i

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10000000)

x,n = map(int,input().split())

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


if n == 0:print(x);exit()

l=[0] * 101

for i in p:
    l[i] =1

diff=1000
ans=0
for i in range(1,101):
    if l[i] == 0 and diff > abs(x-1):
        diff= abs(x-1)
        ans=i

print(ans)

Submission status: Wrong Answer

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


for i in range(1, 101):
    if x - i not in p:
        print(x - i)
        break
    if x + i not in p:
        print(x + i)
        break

Submission status: Wrong Answer

Solution code:
X , N = map(int, input().split())
p = list(map(int,input().split()))
ans = []
if N == 0:
    print(X)
elif X not in  p:
    print(X)
else:
    p = sorted(p)
    p2 = [abs(i-X) for i in p]

    for i in range(p[p2.index(min(p2))],102):
        if i not in p:
            ans.append(i)
            break
    for i in range(p[p2.index(min(p2))], -1, -1):
        if i not in p:
            ans.append(i)
            break
    
    ans = sorted(ans)
    ans2 = [abs(i-X) for i in ans]
    ans2 = sorted(ans2)
    print(ans[ans2.index(min(ans2))])
   # print(min(ans))

Submission status: Wrong Answer

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

min_ = 100
for i in range(0, 102):
    print(i)
    cur = i 
    if cur in P:
        continue
    diff = abs(X - cur)
    if diff < min_:
        min_ = diff

front = X - min_
back = X + min_
if front not in P:
    print(front)
else:
    print(back)

Submission status: Wrong Answer

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

min_ = 100
for i in range(0, 101):
    cur = i 
    if cur in P:
        continue
    diff = abs(X - cur)
    if diff < min_:
        min_ = diff

front = X - min_
back = X + min_
if front not in P:
    print(front)
else:
    print(back)

Submission status: Wrong Answer

Solution code:
x,n=map(int,input().split())
p=[int(x) for x in input().split()]
min=x
gap=x
if x==1:
	print(0)
	exit()
for i in range(102):
	if i in p:
		continue
	else:
		#print("i:",i)
		if abs(x-i) < gap:
			gap=x-i
			min=i
print(min)

Submission status: Wrong Answer

Solution code:
x,n=map(int,input().split())
p=[int(x) for x in input().split()]
min=x
gap=x
if x==1:
	print(0)
for i in range(102):
	if i in p:
		continue
	else:
		#print("i:",i)
		if abs(x-i) < gap:
			gap=x-i
			min=i
print(min)

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np
import math
from collections import deque 
from functools import reduce

# input = sys.stdin.readline
x, y = map(int, input().split())
if y == 0:
    print(x)
    exit()
p = [list(map(int, input().split()))]
p_n = np.array(p)
p_n = p_n.reshape(-1)
pp = np.arange(0, 101)
for i in p_n:
    pp[i] += 10000
sa = min(abs(pp-x))
if sa <= 101:
    if pp[x-sa] >= 10000:
        print(x+sa)
    else:
        print(x-sa)
else:
    print("0")

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np
import math
from collections import deque 
from functools import reduce

# input = sys.stdin.readline
x, y = map(int, input().split())
if y == 0:
    print(x)
    exit()
p = [list(map(int, input().split()))]
p_n = np.array(p)
p_n = p_n.reshape(-1)
pp = np.arange(0, 101)
for i in p_n:
    pp[i] += 10000
sa = min(abs(pp-x))
if sa <= 100:
    if pp[x-sa] >= 10000:
        print(x+sa)
    else:
        print(x-sa)
else:
    print("0")

Submission status: Wrong Answer

Solution code:
x,n=map(int,input().split())
p=[int(x) for x in input().split()]
min=x
gap=x
for i in range(102):
	if i in p:
		continue
	else:
		if abs(x-i) < gap:
			gap=x-i
			min=i
print(min)

Submission status: Wrong Answer

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

if n==0:
	print(x)
else:
	p = list(map(int, input().split()))

	ans = -1
	mn = 10000

	for i in range(1, 101):
		if(p.count(i) == 0):
			d = x - i
			if d<0:
				d = -d
			if d<mn:
				ans = i
				mn = d
	if ans == -1:
		if x<=51:
			ans = 0
		else:
			ans = 101
	print(ans)

Submission status: Wrong Answer

Solution code:
import sys

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

sa = 300

for i in range(101):
    if abs(i-x+1) < sa:
        if not((i+1) in p):
            sa = abs(i-x+1)
            ans = i+1
print(ans)

Submission status: Wrong Answer

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

if n==0:
	print(x)
else:
	p = list(map(int, input().split()))

	ans = -1
	mn = 10000

	for i in range(1, 101):
		if(p.count(i) == 0):
			d = x - i
			if d<0:
				d = -d
			if d<mn:
				ans = i
				mn = d
	if ans == -1:
		if x<=50:
			ans = 0
		else:
			ans = 101
	print(ans)

Submission status: Wrong Answer

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

if n==0:
	print(x)
else:
	p = list(map(int, input().split()))

	ans = -1
	mn = 10000

	for i in range(1, 101):
		if(p.count(i) == 0):
			d = x - i
			if d<0:
				d = -d
			if d<mn:
				ans = i
				mn = d
	print(ans)

Submission status: Wrong Answer

Solution code:
import sys
# from collections import deque
# from collections import Counter
# from math import sqrt
# from math import log
# from math import ceil

# def gcd(a, b):
# 	if(a==0):
# 		return b 
# 	return gcd(b%a,a)

# def sieve(n): 
# 	prime=[True for i in range(n+1)]
# 	p=2
# 	while(p*p<=n): 
# 		if (prime[p]==True): 
# 			for i in range(p*p,n+1,p): 
# 				prime[i]=False
# 		p+=1
# 	prime[0]=False
# 	prime[1]=False
# 	s=set()
# 	for i in range(len(prime)):
# 		if(prime[i]):
# 		s.add(i)
# 	return s 

# alpha=['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
# mod=10**9+7

fast_reader=sys.stdin.readline
fast_writer=sys.stdout.write

def input():
	return fast_reader().strip()

def print(*argv):
	fast_writer(' '.join((str(i)) for i in argv))
	fast_writer('\n')

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

def sep_input():
	return map(int, input().split())

#_______________________________________________________________________________________________________________________________________

x,n=sep_input()
l=list_input()
s=set(l)
i=0
while(True):
	if(x-i not in s):
		print(x+i)
		break
	elif(x+i not in s):
		print(x-i)
		break
	else:
		i+=1

Submission status: Wrong Answer

Solution code:
import sys
# from collections import deque
# from collections import Counter
# from math import sqrt
# from math import log
# from math import ceil

# def gcd(a, b):
# 	if(a==0):
# 		return b 
# 	return gcd(b%a,a)

# def sieve(n): 
# 	prime=[True for i in range(n+1)]
# 	p=2
# 	while(p*p<=n): 
# 		if (prime[p]==True): 
# 			for i in range(p*p,n+1,p): 
# 				prime[i]=False
# 		p+=1
# 	prime[0]=False
# 	prime[1]=False
# 	s=set()
# 	for i in range(len(prime)):
# 		if(prime[i]):
# 		s.add(i)
# 	return s 

# alpha=['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
# mod=10**9+7

fast_reader=sys.stdin.readline
fast_writer=sys.stdout.write

def input():
	return fast_reader().strip()

def print(*argv):
	fast_writer(' '.join((str(i)) for i in argv))
	fast_writer('\n')

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

def sep_input():
	return map(int, input().split())

#_______________________________________________________________________________________________________________________________________

x,n=sep_input()
l=list_input()
s=set(l)
i=0
while(True):
	if(x+i not in s):
		print(x+i)
		break
	elif(x-i not in s):
		print(x-i)
		break
	else:
		i+=1

Submission status: Wrong Answer

Solution code:
import sys
# from collections import deque
# from collections import Counter
# from math import sqrt
# from math import log
# from math import ceil

# def gcd(a, b):
# 	if(a==0):
# 		return b 
# 	return gcd(b%a,a)

# def sieve(n): 
# 	prime=[True for i in range(n+1)]
# 	p=2
# 	while(p*p<=n): 
# 		if (prime[p]==True): 
# 			for i in range(p*p,n+1,p): 
# 				prime[i]=False
# 		p+=1
# 	prime[0]=False
# 	prime[1]=False
# 	s=set()
# 	for i in range(len(prime)):
# 		if(prime[i]):
# 		s.add(i)
# 	return s 

# alpha=['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
# mod=10**9+7

fast_reader=sys.stdin.readline
fast_writer=sys.stdout.write

def input():
	return fast_reader().strip()

def print(*argv):
	fast_writer(' '.join((str(i)) for i in argv))
	fast_writer('\n')

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

def sep_input():
	return map(int, input().split())

#_______________________________________________________________________________________________________________________________________

x,n=sep_input()
l=list_input()
s=set(l)
i=0
while(True):
	if(x+i in s):
		print(x+i)
		break
	elif(x-i in s):
		print(x-i)
		break
	else:
		i+=1

Submission status: Wrong Answer

Solution code:
import sys
x,n =map(int,input().split())
if n == 0:
    print(x)
    sys.exit()
p = list(map(int,input().split()))
p.sort()
wk = 101
an = 0
if n ==100:
    print(0)
    sys.exit()
for i in range(102):
    #if x!=i:
    if p.count(i)==0:
        if abs(x-i)<wk:
            an =i
            wk = abs(x-i)

print(an)

Submission status: Wrong Answer

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

p = set(p)
for i in range(200):
    if x - i not in p:
        print(x - i)
        break
    if n + i not in p:
        print(n + i)
        break

Submission status: Wrong Answer

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

for i in range(200):
    if x - i not in p:
        print(x - i)
        break
    if n + i not in p:
        print(n + i)
        break

Submission status: Wrong Answer

Solution code:
def main():

    x, n = map(int, input().split())
    ans = 0
    if n == 0:
        ans = x
        print(f'{ans}')
        exit()
    else:
        p = [int(i) for i in input().split()]

    for i in range(1, 102):
        if x - i not in p:
            ans = x - i
            break
        if x + i not in p:
            ans = x + i
            break
    
    print(f'{ans}')


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

mn = 999
ans = 0

for i in range(1, 102):
    a = abs(X-i)
    if i not in p:
        if a < mn:
            mn = a
            ans = i

    if a > mn:
        break

print(ans)

Submission status: Wrong Answer

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

mn = 100
ans = 0

for i in range(1, 102):
    a = abs(X-i)
    if i not in p:
        if a < mn:
            mn = a
            ans = i

    if a > mn:
        break

print(ans)

Submission status: Wrong Answer

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

mn = 100
ans = 0

for i in range(1, 101):
    a = abs(X-i)
    if i not in p:
        if a < mn:
            mn = a
            ans = i

    if a > mn:
        break

print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np

X, N = map(int, input().split())
p = list(map(int, input().split()))

abslis = [[]for i in range(102)]*102
for n in range(N):
    abslis[abs(p[n]-X)].append(p[n])
if len(abslis[0]) == 0 :
    print(X)
else :
    for i in range(1,N):
        if len(abslis[i]) != 2: 
            if len(abslis[i]) == 0:
                print(X-i)
            elif len(abslis[i]) ==1:
                print( X+(X-abslis[i][0]) )   
            else :
                print(X-i)
            break

Submission status: Wrong Answer

Solution code:
x,y=map(int,input().split())
if(y==0):
    print(x)
else:
    s=list(map(int,input().split()))
    i=1
    while(1):
        if(abs(x-i) not in s):
            print(abs(x-i))
            break
        if(abs(x+i) not in s):
            print(abs(x+i))
            break
        
        i+=1

Submission status: Wrong Answer

Solution code:
# import math
# x, y = map(int, input().split())
# a = (4 * x - y) / 2
# if a >= 0 and a <= x and a == math.ceil(a):
#     print('Yes')
# else:
#     print('No')


x, n = map(int, input().split())
p = list(map(int, input().split()))
# print(p)
if n == 0:
    print(x)
for i in range(100):
    if x - i not in p:
        print(x - i)
        break
    if x + i not in p:
        print(x + i)
        break

Submission status: Wrong Answer

Solution code:
# import math
# x, y = map(int, input().split())
# a = (4 * x - y) / 2
# if a >= 0 and a <= x and a == math.ceil(a):
#     print('Yes')
# else:
#     print('No')


x, n = map(int, input().split())
p = list(map(int, input().split()))
# print(p)
if n == 0:
    print(x)
for i in range(n):
    if x - i not in p:
        print(x - i)
        break
    if x + i not in p:
        print(x + i)
        break

Submission status: Wrong Answer

Solution code:
X, N = map(int,input().split())
try: plist = list(map(int, input().split()))
except: plist= []

abs1=[]
abs2=[] #[i,絶対チ]
suc =[]

for i in range(1,101):
  if i in plist:
    pass
  else:
    abs1.append(abs(X-i))
    abs2.append([i,abs(X-i)])
if len(abs1)==0:
  abs1.append(X)
  abs2.append([0,X])
A = min(abs1)
for j in range(0,len(abs1)):
  if abs2[j][1]==A:
    suc.append(abs2[j][0])
B =min(suc)
if B==0:
  if X>50:
    print(101)
  else:
    print(0)
else:
  print(B)

Submission status: Wrong Answer

Solution code:
x,y=map(int,input().split())
if(y==0):
    print(x)
else:
    s=list(map(int,input().split()))
    i=1
    while(1):
        if((x-i) not in s):
            print(abs(x-i))
            break
        if((x+i) not in s):
            print(abs(x+i))
            break
        i+=1

Submission status: Wrong Answer

Solution code:
x,y=map(int,input().split())
if(y==0):
    print(x)
else:
    s=list(map(int,input().split()))
    i=1
    while(1):
        if((x-i) not in s):
            print(x-i)
            break
        if((x+i) not in s):
            print(x+i)
            break
        i+=1

Submission status: Wrong Answer

Solution code:
# import math
# x, y = map(int, input().split())
# a = (4 * x - y) / 2
# if a >= 0 and a <= x and a == math.ceil(a):
#     print('Yes')
# else:
#     print('No')
x, n = map(int, input().split())
p = list(map(int, input().split()))
if n == 0:
    print(x)
for i in range(n):
    if x - i not in p:
        print(x - i)
        break
    elif x + i not in p:
        print(x + i)
        break

Submission status: Wrong Answer

Solution code:
X, N = map(int,input().split())
try: plist = list(map(int, input().split()))
except: plist= []

abs1=[]
abs2=[] #[i,絶対チ]
suc =[]

for i in range(1,101):
  if i in plist:
    pass
  else:
    abs1.append(abs(X-i))
    abs2.append([i,abs(X-i)])
if len(abs1)==0:
  abs1.append(X)
  abs2.append([0,X])
A = min(abs1)
for j in range(0,len(abs1)):
  if abs2[j][1]==A:
    suc.append(abs2[j][0])
B =min(suc)
print(B)

Submission status: Wrong Answer

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

ans = -1
for i in range(1, 102):
    if abs(X - i) < abs(X - ans) and i not in p:
        ans = i
print(ans)

Submission status: Wrong Answer

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


all_l = [i for i in range(0,101)]
for p in P:
    all_l.remove(p)




ans = []
c = 0
dic = {}
for a in all_l:
    if c == 0:
        diff = abs(x-a)
    c+=1
    diff_now = abs(x-a)
    diff = min(diff,diff_now)
    memo = diff_now
    if memo == diff:
        dic['{}'.format(str(a))] = diff
        
l = []
for k,v in  dic.items():
    l.append(v)
m = min(l)
k_list = []
for k,v in dic.items():
    if v==m:
        k_list.append(k)
print(int(max(k_list)))

Submission status: Wrong Answer

Solution code:
X, N = map(int, input().split())
P = set(list(map(int, input().split())))

for diff in range(1000):
  if X - diff not in P:
    print(X - diff)
  elif X + diff not in P:
    print(X + diff)

Submission status: Wrong Answer

Solution code:
X, N = map(int,input().split())
try: plist = list(map(int, input().split()))
except: plist= []

abs1=[]
abs2=[] #[i,絶対チ]
suc =[]

for i in range(1,101):
  if i in plist:
    pass
  else:
    abs1.append(abs(X-i))
    abs2.append([i,abs(X-i)])
if len(abs1)==0:
  abs1.append(0)
  abs2.append([0,0])
A = min(abs1)
for j in range(0,len(abs1)):
  if abs2[j][1]==A:
    suc.append(abs2[j][0])
B =min(suc)
if X>=B:
  print(B)
if B-X>=X+1:
  print(0)

Submission status: Wrong Answer

Solution code:
x, n = map(int, input(). split())
m = [0]*200
ans = 0
if n > 0:
  p = list(map(int, input(). split()))
else:
  print(x)
  quit()
for i in range(n):
  l = abs(x-p[i])
  m[l] += 1
if m[0] == 0:
  print(x)
else:
  for j in range(1, 200):
    if m[j] < 2:
      a = x-j
      A = x+j
      if a not in p:
        ans = a
      else:
        ans = A
      break
print(ans)

Submission status: Wrong Answer

Solution code:
X, N = map(int,input().split())
try: plist = list(map(int, input().split()))
except: plist= []

abs1=[]
abs2=[] #[i,絶対チ]
suc =[]

for i in range(1,101):
  if i in plist:
    pass
  else:
    abs1.append(abs(X-i))
    abs2.append([i,abs(X-i)])
if len(abs1)==0:
  abs1.append(0)
  abs2.append([0,0])
A = min(abs1)
for j in range(0,len(abs1)):
  if abs2[j][1]==A:
    if abs2[j][1]-X>=X+1:
      print(0)
      break
    else:
      print(abs2[j][0])
      break

Submission status: Wrong Answer

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

if len(l) == 0 :
    print(x)
    exit()

num = 0
for i in range(len(l)):
    if not((x - num) in l):
        print(x - num)
        exit()

    elif not((x + num) in l):
        print(x + num)
        exit()

    num += 1

Submission status: Wrong Answer

Solution code:
x, n = map(int, input(). split())
m = [0]*200
ans = 0
if n > 0:
  p = list(map(int, input(). split()))
else:
  print(x)
  quit()
for i in range(n):
  l = abs(x-p[i])
  m[l] += 1
if m[0] == 0:
  print(x)
else:
  for j in range(1, 200):
    if m[j] < 2:
      a = x-j
      A = x+j
      b = p.count(a)
      if b == 0:
        ans = a
      else:
        ans = A
      break
print(ans)

Submission status: Wrong Answer

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

ans = 0
for i in range(1, 102):
    if abs(X - i) < abs(ans - i) and i not in p and i != X:
        ans = i

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
x, n = map(int, input(). split())
l = [0]*n
m = [0]*200
ans = 0
p = list()
if n > 0:
  p = list(map(int, input(). split()))
else:
  print(x)
  sys.exit()
for i in range(n):
  l[i] = abs(x-p[i])
  m[l[i]] += 1
if m[0] == 0:
  print(x)
else:
  for j in range(1, 200):
    if m[j] < 2:
      a = x-j
      A = x+j
      b = p.count(a)
      B = p.count(b)
      if b == 0:
        ans = a
      else:
        ans = A
      break
print(ans)

Submission status: Wrong Answer

Solution code:
import sys, os, math, bisect, itertools, collections, heapq, queue
from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict

# import fractions

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)
# lcm = lambda x, y: (x * y) // fractions.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    X, N = il()
    P = il()

    if len(P) == 0:
        print(X)
        exit()

    mx = max(P)
    p = MAX
    ret = 0
    for n in range(-1, mx + 1):
        if n not in P and p > abs(X - n):
            ret = n
            p = X - n
    print(ret)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
X, N = map(int,input().split())
try: plist = list(map(int, input().split()))
except: plist= []

abs1=[]
abs2=[] #[i,絶対チ]

for i in range(1,101):
  if i in plist:
    pass
  else:
    abs1.append(abs(X-i))
    abs2.append([i,abs(X-i)])
if len(abs1)==0:
  abs1.append(0)
  abs2.append([0,0])
A = min(abs1)
for j in range(0,len(abs1)):
  if abs2[j][1]==A:
    if abs2[j][1]>X:
      if abs2[j][1]-X>X+1:
        print(0)
        break
    print(abs2[j][0])
    break

Submission status: Wrong Answer

Solution code:
import sys, os, math, bisect, itertools, collections, heapq, queue
from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict

# import fractions

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)
# lcm = lambda x, y: (x * y) // fractions.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    X, N = il()
    P = il()

    if len(P) == 0:
        print(X)
        exit()

    mx = max(P)
    p = MAX
    ret = 0
    for n in range(mx + 1):
        if n not in P and p > abs(X - n):
            ret = n
            p = X - n
    print(ret)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
x, n =map(int, input().split())
if n>0:
    p=list(map(int, input().split()))
    p.sort()
    dif=p[n-1]-x
    ans=200
    for i in range(0,x-p[0]+1):
        if x-i in p:
            a=0
        else:
            ans=x-i
            dif=i
            break
    for i in range(0,dif):
        if x+i in p:
            a=0
        else:
            ans=x+i
            break
    if ans==200:
        if x>50:
            print(101)
        else:
            print(0)
    else:
        print(ans)
else:
    print(x)

Submission status: Wrong Answer

Solution code:
X, N = map(int,input().split())
try: plist = list(map(int, input().split()))
except: plist= []

abs1=[]
abs2=[] #[i,絶対チ]

for i in range(1,101):
  if i in plist:
    pass
  else:
    abs1.append(abs(X-i))
    abs2.append([i,abs(X-i)])
if len(abs1)==0:
  abs1.append(0)
  abs2.append([0,0])
A = min(abs1)
for j in range(0,len(abs1)):
  if abs2[j][1]==A:
    print(abs2[j][0])
    break

Submission status: Wrong Answer

Solution code:
import sys
x, n = map(int, input(). split())
l = [0]*n
m = [0]*200
ans = 0
p = list()
if n > 0:
  p = list(map(int, input(). split()))
else:
  print(x)
  sys.exit()
for i in range(n):
  l[i] = abs(x-p[i])
  m[l[i]] += 1
if m[0] == 0:
  print(x)
else:
  for j in range(1, 200):
    if m[j] != 2:
      a = x-j
      A = x+j
      b = p.count(a)
      B = p.count(b)
      if b == 0:
        ans = a
      else:
        ans = A
      break
print(ans)

Submission status: Wrong Answer

Solution code:
x, n =map(int, input().split())
if n>0:
    p=list(map(int, input().split()))
    p.sort()
    dif=p[n-1]-x
    ans=200
    for i in range(0,x-p[0]+1):
        if x-i in p:
            a=0
        else:
            ans=x-i
            dif=i
            break
    for i in range(0,dif):
        if x+i in p:
            a=0
        else:
            ans=x+i
            break
    if ans==200:
        print(101)
    else:
        print(ans)
else:
    print(x)

Submission status: Wrong Answer

Solution code:
X, N = map(int,input().split())
if N ==100:
  print(0)
else:
  pass

try:
  plist = list(map(int, input().split()))
except:
	plist =[]

abst1 = []
abst2 = []
suci = []
for i in range(1,101):
  if i in plist:
    pass
  else:
    abst1.append(abs(X-i))
    abst2.append([i,abs(X-i)])

if N!=100:
  A=min(abst1)
else:
  pass
  
try:
  for j in range(0,len(abst1)):
    if abst2[j][1] == A:
      if abst2[j][0]>X:
        if abst2[j][0]-X>=X+1:
          print(0)
          break
      print(abst2[j][0])
      break
except:
  if N!=0:
    pirnt(0)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10000000)

x,n = map(int,input().split())

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


if n == 0:print(x);exit()

l=[0] * 100

for i in p:
    l[i-1] =1

diff=min(101-x,x)
ans=0 if x < 51 else 101
for i in range(100):
    if l[i] == 0 and diff > abs(x-(i+1)):
        diff= abs(x-(i+1))
        ans=i+1

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10000000)

x,n = map(int,input().split())

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


if n == 0:print(x);exit()

l=[0] * 100

for i in p:
    l[i-1] =1

print(l)

diff=min(101-x,x)
ans=0 if x < 51 else 101
for i in range(100):
    if l[i] == 0 and diff > abs(x-(i+1)):
        diff= abs(x-(i+1))
        ans=i+1

print(ans)

Submission status: Wrong Answer

Solution code:
x,n = map(int,input().split())
p = list(map(int,input().split()))
flag = [True] * 101

for i in p:
    flag[i] = False

for i in range(101):
    low = max(x-i, 0)
    high = min(x+i, 100)
    if flag[low]:
        print(low)
        break
    elif flag[high]:
        print(high)
        break

Submission status: Wrong Answer

Solution code:
import sys
x, n = map(int, input(). split())
l = [0]*n
m = [0]*101
ans = 0
p = list()
if n > 0:
  p = list(map(int, input(). split()))
else:
  print(x)
  sys.exit()
for i in range(n):
  l[i] = abs(x-p[i])
  m[l[i]] += 1
if m[0] == 0:
  print(x)
else:
  for j in range(1, 101):
    if m[j] != 2:
      a = x-j
      A = x+j
      b = p.count(a)
      B = p.count(b)
      if b == 0:
        ans = a
        if j > x:
          ans = 0
      else:
        ans = A
        if j > x:
          ans = 0
      break
print(ans)

Submission status: Wrong Answer

Solution code:
x,n = map(int,input().split())
p = list(map(int,input().split()))
flag = [True] * 101

for i in p:
    flag[i] = False

for i in range(101):
    low = max(x-i, 0)
    high = min(x+i, 100)
    if low:
        print(low)
        break
    elif high:
        print(high)
        break

Submission status: Wrong Answer

Solution code:
import sys
x, n = map(int, input(). split())
l = [0]*n
m = [0]*101
ans = 0
p = list()
if n > 0:
  p = list(map(int, input(). split()))
else:
  print(x)
  sys.exit()
for i in range(n):
  l[i] = abs(x-p[i])
  m[l[i]] += 1
if m[0] == 0:
  print(x)
else:
  for j in range(1, 101):
    if m[j] != 2:
      a = x-j
      A = x+j
      b = p.count(a)
      B = p.count(b)
      if b == 0:
        ans = a
      else:
        ans = A
      break
print(ans)