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()))
list = [0] * 101
list[0] = 1
res = X
dist = 102
for p in P:
    list[p] = 1
for i in range(101):
    if list[i] == 0:
        if abs(i - X) < dist:
            dist = abs(i - X)
            res = i
        elif abs(i - X) == dist:
            res = min(res,i)
print(res)

Submission status: Wrong Answer

Solution code:

import numpy

x,n = map(int,input().split())
try:
    p = list(map(int,input().split()))
except EOFError:
    p =[]

a = numpy.abs(list(map(lambda z: z-x,p))).tolist()

if 0 not in a:
    print(x)
else:
    for i in range(1,n,1):
        if a.count(i) == 2:
            continue
        elif a.count(i) == 1:
            if x+i not in p:
                print(x+i)
                break
        if x > 0:
            print(x-i)
        else:
            print(x+i)
        break

Submission status: Wrong Answer

Solution code:
x,n=map(int,input().split())
p=list(map(int,input().split()))
if n==0:
  print(x)
  exit()
for i in range(1,n):
  if (x-i) not in p:
    print(x-i)
    break
  elif (x+i) not in p:
    print(x+i)
    break
  else:
    continue

Submission status: Wrong Answer

Solution code:
x,n = list(map(int, input().split()))
if n == 0:
  print(x)
else:
  p = list(map(int, input().split()))
  hoge = [i for i in range(x - n, x + n + 1)]

Submission status: Wrong Answer

Solution code:
x,n =map(int,input().split())
if n ==0:
    print(x)
p =list(map(int,input().split()))
l = []
for i in range(51):
    if x-i not in p and x+i not in p:
        print(min(x-i,x+i))
        exit()
    elif x-i not in p and x+i in p:
        print(x-i)
        exit()
    elif x-i in p and x+i not in p:
        print(x+i)
        exit()

Submission status: Wrong Answer

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

L=[]
for i in range(100):
    L.append(i+1)
for i in range(n):
    L.remove(P[i])

m=99

for i in range(len(L)):
    if abs(L[i]-x)<=m:
        m=abs(L[i]-x)

if n==0:
    print(x)
elif (x==1) and (1 not in L):
    print(0)
elif (x==100) and (99 not in L) and (100 not in L):
    print(101)
elif (x-m in L) or (x-m==0):
    print(x-m)
elif (x+m in L) or (x+m==101) :
    print(x+m)

Submission status: Wrong Answer

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

L=[]
for i in range(100):
    L.append(i+1)
for i in range(n):
    L.remove(P[i])

m=99

for i in range(len(L)):
    if abs(L[i]-x)<=m:
        m=abs(L[i]-x)

if n==0:
    print(x)
elif (x-m in L) or (x-m==0):
    print(x-m)
elif (x+m in L) or (x+m==101) :
    print(x+m)

Submission status: Wrong Answer

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

L=[]
for i in range(100):
    L.append(i+1)
for i in range(n):
    L.remove(P[i])

m=99

for i in range(len(L)):
    if abs(L[i]-x)<=m:
        m=abs(L[i]-x)

if n==0:
    print(x)
elif (x-m in L) or (x-m==0):
    print(x-m)
else :
    print(x+m)

Submission status: Wrong Answer

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

L=[]
for i in range(100):
    L.append(i+1)
for i in range(n):
    L.remove(P[i])

m=99

for i in range(len(L)):
    if abs(L[i]-x)<=m:
        m=abs(L[i]-x)

if n==0:
    print(x)
elif x-m in L:
    print(x-m)
else :
    print(x+m)

Submission status: Wrong Answer

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

L=[]
for i in range(100):
    L.append(i+1)
for i in range(n):
    L.remove(P[i])

m=99

for i in range(len(L)):
    if abs(L[i]-x)<=m:
        m=abs(L[i]-x)

if x-m in L:
    print(x-m)
else :
    print(x+m)

Submission status: Wrong Answer

Solution code:
import numpy as np
def forbidden_list():
    X, N = map(int,input().split())
    p = list(map(int, input().split()))
    lis = np.array([1 for i in range(102)])
    lis[p] = 0
    index = X
    ma = 102 - X
    for i in range(max(X,ma)):
        if index - i >= 0 and lis[index-i]:
            print(index-i)
            break
        elif index + i <= 100 and lis[index + i]:
            print(index + i)
            break
    
forbidden_list()

Submission status: Wrong Answer

Solution code:
import numpy as np
def forbidden_list():
    X, N = map(int,input().split())
    p = list(map(int, input().split()))
    lis = np.array([1 for i in range(101)])
    lis[p] = 0
    index = X
    ma = 101 - X
    for i in range(max(X,ma)):
        if index - i >= 0 and lis[index-i]:
            print(index-i)
            break
        elif index + i <= 100 and lis[index + i]:
            print(index + i)
            break
    
forbidden_list()

Submission status: Wrong Answer

Solution code:
x, n = map(int, input().split())
if n != 0:
    l = list(map(int, input().split()))
else:
    l = []

diff = 10**10
ans = 10**10

for i in range(101):
    if i in l:
        continue
    else:
        if abs(x-i) < diff:
            ans = i
            diff = abs(x-i)

print(ans)

Submission status: Wrong Answer

Solution code:
import sys

X, N = map(int,input().split())
P = []
if N != 0:
  P = list(map(int,input().split()))

table = [True]*101

for i in range(N):
  table[P[i]] = False

ans = 1e18
dif = 1e18

for i in range(1,101):
  if table[i] == False:
    continue
  elif abs(i-X) > dif:
    continue
  elif abs(i-X) == dif:
    if i < ans:
      ans = i
      dif = abs(i-X)
  else:
    ans = i
    dif = abs(i-X)

print(ans)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sun Sep  6 12:13:57 2020

@author: liang
"""

X, N = map(int,input().split())
p = {int(x) for x in input().split()}


ans = 0
i = 0

while True:
    tmp = X + i
    if tmp not in p:
        ans = tmp
        break
    tmp = X - i
    if tmp not in p:
        ans = tmp
        break
    i += 1
print(ans)

Submission status: Wrong Answer

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

min = 100

if N !=0:
  Plist = list(map(int,input().split()))
  anslist = [i for i in range(101)]
  anslist.append(-1)
  #anslist.remove(0)
  Plist = sorted(Plist)
  for i in range(N):
    anslist.remove(Plist[i])
    temp =100
  for i in range(len(anslist)):
    if min >abs(anslist[i]-X) :
      min = abs(anslist[i]-X)
      temp = anslist[i]
  print (temp)
else :
  print (X)

Submission status: Wrong Answer

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

min = 100

if N !=0:
  Plist = list(map(int,input().split()))
  anslist = [i for i in range(101)]
  anslist.remove(0)
  Plist = sorted(Plist)
  for i in range(N):
    anslist.remove(Plist[i])
    temp =100
  for i in range(len(anslist)):
    if min >abs(anslist[i]-X) :
      min = abs(anslist[i]-X)
      temp = anslist[i]
  print (temp)
else :
  print (X)

Submission status: Wrong Answer

Solution code:
x,n = [int(x) for x in input().split()]
if n == 0:
  print(x)
else:
  p = [int(x) for x in input().split()]
  p.sort()
  ans = []
  for i in range(101):
    if i in p:
      continue
    b = abs(x - i)
    ans.append((i,b))
  ans = sorted(ans,key = lambda x: x[1])
  print(ans[0][0])

Submission status: Wrong Answer

Solution code:
x,n = [int(x) for x in input().split()]
if n == 0:
  print(x)
else:
  p = [int(x) for x in input().split()]
  p.sort()
  a = 1000
  for i in range(n):
    b = abs(x - p[i])
    if b < a:
      a = i
  print(a)

Submission status: Wrong Answer

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

    tmp = -100
    diff = 10000000
    for i in range(0,102):
        if abs(x-i)<diff and i not in p:
            tmp = i
            diff = abs(x-i)
            
    print(tmp)
else:
    print(n)

Submission status: Wrong Answer

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

    tmp = -100
    diff = 10000000
    for i in range(-100,201):
        if abs(x-i)<diff and i not in p:
            tmp = i
            diff = abs(x-i)
            
    print(tmp)
else:
    print(n)

Submission status: Wrong Answer

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

    tmp = 0
    diff = 10000000
    for i in range(-100,201):
        if abs(x-i)<diff and i not in p:
            tmp = i
            diff = abs(x-i)
            
    print(tmp)
else:
    print(n)

Submission status: Wrong Answer

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

    tmp = 0
    diff = 10000000
    for i in range(200):
        if abs(x-i)<diff and i not in p:
            tmp = i
            diff = abs(x-i)
            
    print(tmp)
else:
    print(n)

Submission status: Wrong Answer

Solution code:
x, n = list(map(int, input().split()))
q = list(map(int, input().split()))
p = [i for i in range(1, 102) if i not in q]

for i in range(len(p)):
    if p[i] < x:
        continue
    # p[i] >= x
    break

if p[i] == x:
    print(p[i])
else:
    if p[i] - x < x - p[i - 1]:
        print(p[i])
    else:
        print(p[i - 1])

Submission status: Wrong Answer

Solution code:

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

if l == []:
    print(x)
    exit()

x_a = x
for i in range(100):
    x -= 1
    x_a += 1
    if x not in l:
        print(x)
        exit()
    if x_a not in l:
        print(x_a)
        exit()

Submission status: Wrong Answer

Solution code:

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

if l == []:
    print(x)
    exit()

for i in range(100):
    x -= 1
    if x not in l:
        print(x)
        exit()

Submission status: Wrong Answer

Solution code:
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    x,n=map(int,input().split())
    P = list(map(int,input().split()))
    n_lis = [0]*102
    print(n_lis)
    for p in P:
        n_lis[p] += 1
    dis = 0
    while 1:
        if n_lis[x-dis] == 0:
            print(x-dis)
            break
        elif n_lis[x+dis] == 0:
            print(x+dis)
            break
        dis += 1

if __name__=='__main__':
    main()

Submission status: Wrong Answer

Solution code:
import numpy

x,n = map(int,input().split())
try:
    p = list(map(int,input().split()))
except EOFError:
    p =[]

a = numpy.abs(list(map(lambda z: z-x,p))).tolist()

if 0 not in a:
    print(x)
else:
    for i in range(1,n,1):
        if a.count(i) == 2:
            continue
        elif a.count(i) == 1:
            if x+i not in p:
                print(x+i)
                break
        if x > 0:
            print(x-i)
        else:
            print(x+i)
        break

Submission status: Wrong Answer

Solution code:
import numpy

x,n = map(int,input().split())
try:
    p = list(map(int,input().split()))
except EOFError:
    p =[]

a = numpy.abs(list(map(lambda z: z-x,p))).tolist()

if 0 not in a:
    print(x)
else:
    for i in range(1,n,1):
        if a.count(i) == 2:
            continue
        elif a.count(i) == 1:
            if x+i not in p:
                print(x+i)
                break
        print(x-i)
        break

Submission status: Wrong Answer

Solution code:
import numpy

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

a = numpy.abs(list(map(lambda z: z-x,p))).tolist()

if n==0 or 0 not in a:
    print(x)
else:
    for i in range(1,n,1):
        if a.count(i) == 2:
            continue
        elif a.count(i) == 1:
            if x+i not in p:
                print(x+i)
                break
        print(x-i)
        break

Submission status: Wrong Answer

Solution code:
import numpy

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

a = numpy.abs(list(map(lambda z: z-x,p))).tolist()
print(a)

if n==0 or 0 not in a:
    print(x)
else:
    for i in range(1,n,1):
        if a.count(i) == 2:
            continue
        elif a.count(i) == 1:
            if x+i not in p:
                print(x+i)
                break
        print(x-i)
        break

Submission status: Wrong Answer

Solution code:
import numpy

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

a = numpy.abs(list(map(lambda z: z-x,p))).tolist()
#q = numpy.abs(list(map(lambda z: z-x,p)))
#q.sort
#p = numpy.abs(list((map(int,input().split()))))

if 0 not in a:
    print(x)
else:
    for i in range(1,n,1):
        if a.count(i) == 2:
            continue
        elif a.count(i) == 1:
            if x+i not in p:
                print(x+i)
                break
        print(x-i)
        break

Submission status: Wrong Answer

Solution code:
import numpy

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

a = numpy.abs(list(map(lambda z: z-x,p))).tolist()
#q = numpy.abs(list(map(lambda z: z-x,p)))
#q.sort
#p = numpy.abs(list((map(int,input().split()))))

if 0 not in a:
    print(x)
else:
    for i in range(1,n,1):
        if a.count(i) == 2:
            continue
        elif a.count(i) == 1:
            if x+i in p:
                print(x-i)
                break
        print(x+i)
        break

Submission status: Wrong Answer

Solution code:

def main():
    x, n = map(int, input().split(" "))
    p =[]
    dif = 1e2
    ans = 0
    l_a = [i for i in range(101)]
    if n != 0:
        p = list(map(int, input().split(" ")))
    for ele in l_a[::-1]:
        if abs(x - ele) <= dif and ele not in p:
            ans = ele
            dif = abs(x - ele)
    print(ans)
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:

def main():
    x, n = map(int, input().split(" "))
    p =[]
    dif = 1e2
    ans = 0
    l_a = [i for i in range(100)]
    if n != 0:
        p = list(map(int, input().split(" ")))
    for ele in l_a[::-1]:
        if abs(x - ele) <= dif and ele not in p:
            ans = ele
            dif = abs(x - ele)
    print(ans)
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def resolve():
    X, N = list(map(int, input().split()))
    P = list(map(int, input().split()))
    ans = float("inf")
    for i in range(-100, 101):
        if i in P:
            continue
        if abs(X-ans) > abs(X-i):
            ans = i
        elif abs(X-ans) == abs(X-i):
            ans = min(ans, i)
    print(ans)


if '__main__' == __name__:
    resolve()

Submission status: Wrong Answer

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

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

asc_val = 1000
desc_val = 1000
for i in range(x, 101):
    if i not in ps:
        asc_val = i
        break

for i in reversed(range(0, x)):
    if i not in ps:
        desc_val = i
        break

if asc_val == 1000 and desc_val == 1000:
    if x <= 50:
        print(0)
    else:
        print(101)

if asc_val == 1000:
    print(desc_val)
    exit()

if desc_val == 1000:
    print(asc_val)
    exit()

if abs(asc_val-x) >= abs(desc_val-x):
    print(desc_val)
else:
    print(asc_val)

Submission status: Wrong Answer

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

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

asc_val = 1000
desc_val = 1000
for i in range(x, 101):
    if i not in ps:
        asc_val = i
        break

for i in reversed(range(0, x)):
    if i not in ps:
        desc_val = i
        break

if asc_val == 1000 and desc_val == 1000:
    print('')
    exit()

if asc_val == 1000:
    print(desc_val)
    exit()

if desc_val == 1000:
    print(asc_val)
    exit()

if abs(asc_val-x) >= abs(desc_val-x):
    print(desc_val)
else:
    print(asc_val)

Submission status: Wrong Answer

Solution code:
x, n = map(int, input().split())
ps = list(map(int, input().split()))
ps_srt = sorted(ps)

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

asc_val = 1000
desc_val = 1000
for i in range(x, 101):
    if i not in ps_srt:
        asc_val = i
        break

for i in reversed(range(1, x)):
    if i not in ps_srt:
        desc_val = i
        break

if abs(asc_val-x) >= abs(desc_val-x):
    print(desc_val)
else:
    print(asc_val)

Submission status: Wrong Answer

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

if len(P) == 0:
  print(X)
else:
  for i in range(1,10000):
    if P.count(X-i) == 0:
      print(X-i)
      break
    elif P.count(X+i) == 0:
      print(X+i)
      break
    else:
      continue

Submission status: Wrong Answer

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

if len(P) == 0:
  print(X)
else:
  for i in range(1,101):
    if P.count(X-i) == 0:
      print(X-i)
      break
    elif P.count(X+i) == 0:
      print(X+i)
      break
    else:
      continue

Submission status: Wrong Answer

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

if len(P) == 0:
  print(X)
else:
  for i in range(1,100):
    if P.count(X-i) == 0:
      print(X-i)
      break
    elif P.count(X+i) == 0:
      print(X+i)
      break
    else:
      continue

Submission status: Wrong Answer

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

if len(P) == 0:
  print(X)
else:
  for i in range(1,100):
    if P.count(X-i) == 0:
      print(X-i)
      break
    elif P.count(X+1) == 0:
      print(X+1)
      break
    else:
      continue

Submission status: Wrong Answer

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

p = list(map(int,input().split()))
s = []

for i in range(101):
  if i not in p:
    s.append(i)

    
if s == [0]:
  print(0)

else:
  

  k = abs(x-s[0])
  del s[0]
  for j in range(100-n):
    if abs(x-s[j]) < k:
      k = abs(x-s[j])
    else:
      answer = s[j-1]
      break
  else:
    answer = s[100-n-1]
  print(answer)

Submission status: Wrong Answer

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

p = list(map(int,input().split()))
s = []

for i in range(101):
  if i not in p:
    s.append(i)

    
if s == [0]:
  print(x)

else:
  

  k = abs(x-s[0])
  del s[0]
  for j in range(100-n):
    if abs(x-s[j]) < k:
      k = abs(x-s[j])
    else:
      answer = s[j-1]
      break
  else:
    answer = s[100-n-1]
  print(answer)

Submission status: Wrong Answer

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

P.sort(reverse=True)
P += [-1000]
p_idx = 0
min_difference = 101
ans = 101
for num in range(101, -2, -1):
    if num == P[p_idx]:
        p_idx += 1
    else:
        if abs(X - num) <= min_difference:
            min_difference = abs(X - num)
            ans = num
print(num)

Submission status: Wrong Answer

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

if N ==0:
    print(X)

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

    length =np.zeros(101)
    length =list(length)

    for i in range(len(length)):
        length[i]= abs(X-i)

    for i in range(N):
        length[p[i]]=1000

    ans = length.index(min(length))
    print(ans)

Submission status: Wrong Answer

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

if N ==0:
    print(X)

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

    length =np.zeros(101)
    length =list(length)

    for i in range(len(length)):
        length[i]= abs(X-i)

    for i in range(len(p)):
        length[p[i]]=1000

    ans = length.index(min(length))
    print(ans)

Submission status: Wrong Answer

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

if N ==0:
    print(X)

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

    length =np.zeros(101)
    length =list(length)

    for i in range(len(length)):
        length[i]= abs(X-i)

    for i in range(len(p)):
        length[p[i]]=100

    ans = length.index(min(length))
    print(ans)

Submission status: Wrong Answer

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

if N ==0:
    print(X)

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

    #距離格納行列
    length =np.zeros(101)
    length =list(length)

    for i in range(len(length)):
        length[i]= abs(X-i)

    for i in range(len(p)):
        length[p[i]]=100

    ans = length.index(min(length))
    print(ans)

Submission status: Wrong Answer

Solution code:
import sys
a, b = map(int, input().split())
if b != 0:
    li = list(set(map(int, input().split(' '))))
    if a not in li:
        print(a)
        sys.exit()
    li.sort()
    ma = max(li)
    mi = min(li)
    al = [i for i in range(mi, ma+1)]
    su = [v for v in al if not v in li]

    for i in range(1, len(al)):

        if a-i in su or a+i in su:
            if a-i in su:
                print(a-i)
                break
            elif a+i in su:
                print(a+i)
                break
else:
    print(a)

Submission status: Wrong Answer

Solution code:
a, b = map(int, input().split())
if b != 0:
    li = list(set(map(int, input().split(' '))))
    li.sort()
    ma = max(li)
    mi = min(li)
    al = [i for i in range(mi, ma+1)]
    su = [v for v in al if not v in li]

    for i in range(1, len(al)):

        if a-i in su or a+i in su:
            if a-i in su:
                print(a-i)
                break
            elif a+i in su:
                print(a+i)
                break
else:
    print(a)

Submission status: Wrong Answer

Solution code:
a, b = map(int, input().split())
if b != 0:
    li = list(map(int, input().split(' ')))
    li.sort()
    ma = max(li)
    mi = min(li)
    al = [i for i in range(mi, ma+1)]
    su = [v for v in al if not v in li]

    for i in range(1, len(al)):

        if a-i in su or a+i in su:
            if a-i in su:
                print(a-i)
                break
            elif a+i in su:
                print(a+i)
                break
else:
    print(a)

Submission status: Wrong Answer

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

d = 10 ** 9
ans = 0
for i in range(101):
    if (i in P):
        continue
    if (abs(X - i) < d):
        ans = i
        d = abs(X - i)
print(ans)

Submission status: Wrong Answer

Solution code:
x,n = map(int, input().split())
l = sorted(list(map(int, input().split())))
num = [0] * 101

for i in l:
    num[i] += 1
ans = 0
minNum = float('inf')
for i in range(1,len(num)):
    if num[i] == 0:
        numx = abs(x - i)
        if numx < minNum:
            minNum = numx
            ans = i
print(ans)

Submission status: Wrong Answer

Solution code:
x,n = map(int, input().split())
l = sorted(list(map(int, input().split())))
num = [0] * 101

for i in l:
    num[i] += 1
ans = 0
minNum = float('inf')
for i in range(len(num)):
    if num[i] == 0:
        numx = abs(x - i)
        if numx < minNum:
            minNum = numx
            ans = i

print(ans)

Submission status: Wrong Answer

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

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

if x not in p:
  print(p)

else:
  flag = True
  d = 0
  while flag == True:
    d += 1
    if x-d not in p:
      print(x-d)
      flag = False
    elif x+d not in p:
      print(x+d)
      flag = False

Submission status: Wrong Answer

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

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

if x not in p:
  print(p)

else:
  flag = True
  d = 0
  while flag == True:
    d += 1
    if x+d not in p:
      print(x+d)
      flag = False
    elif x-d not in p:
      print(x-d)
      flag = False

Submission status: Wrong Answer

Solution code:
x, n = map(int, input().split())
p = list(map(int, input().split()))
ans = 9999999999
lists = []
if n == 0:
    print(x)
    exit()
for i in range(101):
    if i not in p:
        print(i)
        lists.append(i)
for i in lists:
    if ans > abs(x - i):
        ans = abs(x-i)
        m = i

print(m)

Submission status: Wrong Answer

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

for i in range(0,101):
  if i not in p:
    notp.append(i)

for j in range(len(notp)):
  if j != len(notp)-1:
    
    if abs(x-notp[j+1]) >= abs(x-notp[j]):
      print(notp[j])
      break
  else:
    print(notp[j])
    break

Submission status: Wrong Answer

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

Q = [q for q in range(-1, 101) if q not in P]  # -1以上101以下整数のうちPに存在しないもの
ans = min(Q, key=lambda q: (abs(q - X), q))  # maspyさん解法
print(ans)

Submission status: Wrong Answer

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

Q = [q for q in range(0, 100) if q not in P]  # -1以上101以下整数のうちPに存在しないもの
ans = min(Q, key=lambda q: (abs(q - X), q))  # maspyさん解法
print(ans)

Submission status: Wrong Answer

Solution code:
X,N = map(int,input().split())
if  N == 0:
  print(X)
  exit()
array = sorted(list(map(int,input().split())))
for i in range(1,200):
    X_plus = X + i
    X_pull = X - i
    if not X_pull in array:
      print(X_pull)
      exit()
    if not X_plus in array:
      print(X_plus)
      exit()

Submission status: Wrong Answer

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

p.sort()

q = []

j = 0

for i in range(101):
    if 0 <= j <= N - 1:
        if i == p[j]:
            q.append(0)
            j += 1
            continue
    q.append(i)

i = X
j = X

while 0 < i and j < 101:
    if q[i] != 0:
        print(i)
        exit(0)
    elif q[j] != 0:
        print(j)
        exit(0)
    i -= 1
    j += 1

if i == 0 or i == 1:
    print(i)
elif j == 101:
    print(101)

Submission status: Wrong Answer

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

p.sort()

q = []

j = 0

for i in range(101):
    if 0 <= j <= N - 1:
        if i == p[j]:
            q.append(0)
            j += 1
            continue
    q.append(i)

i = X
j = X

while 1 < i and j < 101:
    if q[i] != 0:
        print(i)
        exit(0)
    elif q[j] != 0:
        print(j)
        exit(0)
    i -= 1
    j += 1

if i == 0 or i == 1:
    print(i)
elif j == 101:
    print(101)

Submission status: Wrong Answer

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

p.sort()

q = []

j = 0

for i in range(101):
    if 0 <= j <= N - 1:
        if i == p[j]:
            q.append(0)
            j += 1
            continue
    q.append(i)

i = X
j = X

while 0 < i and j < 101:
    if q[i] != 0:
        print(i)
        exit(0)
    elif q[j] != 0:
        print(j)
        exit(0)
    i -= 1
    j += 1

if i == 0:
    print(0)
elif j == 101:
    print(101)

Submission status: Wrong Answer

Solution code:
import math

X, N = map(int, input().split())
if N == 0:
  print(X)
else:
  p = list(map(int, input().split()))
  q = [int(i)-10 for i in range(121)]
  print(q)

  for i in p:
    q.remove(i)

  ans = 0
  r0 = 100000
  for j in q:
    r = abs(j-X)
    if r0 > r:
      r0 = r
      ans = j
  print(ans)

Submission status: Wrong Answer

Solution code:
import math

X, N = map(int, input().split())
if N == 0:
  print(X)
else:
  p = list(map(int, input().split()))
  q = [int(i)-100 for i in range(201)]
  #print(q)

  for i in p:
    q.remove(i)

  ans = 0
  r0 = 100000
  for j in q:
    r = abs(j-X)
    if r0 > r:
      r0 = r
      ans = j
  print(ans)

Submission status: Wrong Answer

Solution code:
import math

X, N = map(int, input().split())
if N == 0:
  print(X)
else:
  p = list(map(int, input().split()))
  q = [int(i)-100 for i in range(201)]
  #print(q)

  for i in p:
    q.remove(i)

  ans = 0
  r0 = 101
  for j in q:
    r = abs(j-X)
    if r0 > r:
      r0 = r
      ans = j
  print(ans)

Submission status: Wrong Answer

Solution code:
import math

X, N = map(int, input().split())
if N == 0 or N == 100:
  print(X)
else:
  p = list(map(int, input().split()))
  q = [int(i)+1 for i in range(100)]
  #print(q)

  for i in p:
    q.remove(i)

  ans = 0
  r0 = 101
  for j in q:
    r = abs(j-X)
    if r0 > r:
      r0 = r
      ans = j
  print(ans)

Submission status: Wrong Answer

Solution code:
import math

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

  q = [int(i)+1 for i in range(100)]
  #print(q)

  for i in p:
    q.remove(i)

  ans = 0
  r0 = 101
  for j in q:
    r = abs(j-X)
    if r0 > r:
      r0 = r
      ans = j
  print(ans)

Submission status: Wrong Answer

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

i=0

while True:
    if not x-i in a:
        print(x-i)
        break
    if not x+i in a:
        print(x+1)
        break
    i+=1

Submission status: Wrong Answer

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

ans_list = [300]
for i in range(1, 101):
    if i not in list:
        if abs(x-i) < abs(x-ans_list[-1]):
            ans_list.append(i)

print(ans_list)
ans_list.sort(key=lambda y: abs(x-y))
print(ans_list[0])

Submission status: Wrong Answer

Solution code:
x, n = map(int, input().split())
if n == 0:
    champ = x
else:
    p = list(map(int, input().split()))
    p.sort()
    min = 100
    sa = 0
    champ = 0
    for i in range(-1, 100):
        if i in p:
            continue
        sa = abs(x - i)
        if min == sa:
            break
        elif min > sa:
            min = sa
            champ = i
            
print(champ)

Submission status: Wrong Answer

Solution code:
x, n = map(int, input().split())
if n == 0:
    champ = x
else:
    p = list(map(int, input().split()))
    p.sort()
    min = 100
    sa = 0
    champ = 0
    for i in range(-100, 100):
        if i in p:
            continue
        sa = abs(x - i)
        if min == sa:
            break
        elif min > sa:
            min = sa
            champ = i
            
print(champ)

Submission status: Wrong Answer

Solution code:
x, n = map(int, input().split())
if n == 0:
    champ = x
else:
    p = list(map(int, input().split()))
    p.sort()
    min = 100
    sa = 0
    champ = 0
    for i in range(100):
        if i in p:
            continue
        sa = abs(x - i)
        if min == sa:
            break
        elif min > sa:
            min = sa
            champ = i
            
print(champ)

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()
min = 100
sa = 0
champ = 0
for i in range(100):
    if i in p:
        continue
    sa = abs(x - i)
    if min == sa:
        break
    elif min > sa:
        min = sa
        champ = i
            
print(champ)

Submission status: Wrong Answer

Solution code:
X, N = list(map(int, input().split()))
if N!=0:
    P = set(list(map(int, input().split())))
else:
    print(X)
    exit(0)

dist = 100
r = None
for i in range(100, -1, -1):
    if not i in P and abs(X-i) <= dist:
        dist = abs(X-i)
#        print (i, dist)
        r = i

print(r)