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

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

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

nums = list(map(int,input().split()))
nums2 = [False]*101
# print(nums)
for p in nums:
    nums2[p] = True

for i in range(50):
    # print(x-i,x+i)
    if x - i < 0:
        print(-1)
        exit(0)
    elif x + i > 100:
        print(101)
        exit(0)
    elif nums2[x-i]==False:
        print(x-i)
        exit(0)
    elif nums2[x+i]==False:
        print(x+i)
        exit(0)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys


def input():
    return sys.stdin.readline()


def resolve():
    x, n = map(int, input().split())

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

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

    max_p = max(p_list)
    not_p_list = []


    flag = False
    for j in range(max_p):
        j1 = j+1
        if j1 in p_list:
            pass
        else:
            not_p_list.append(j1)



    min_num = 999
    ans = 0

    for i in not_p_list:

        m = abs(x - i)
        if min_num >= m:
            if min_num == m:
                continue
            min_num = m
            ans = i

    print(ans)

if __name__ == "__main__":
    resolve()

Submission status: Wrong Answer

Solution code:
def resolve():
    import sys
    input = sys.stdin.readline
    # 整数 1 つ
    # n = int(input())
    # 整数複数個
    x, n = map(int, input().split())
    # 整数 N 個 (改行区切り)
    # N = [int(input()) for i in range(N)]
    # 整数 N 個 (スペース区切り)
    # N = list(map(int, input().split()))
    # 整数 (縦 H 横 W の行列)
    # A = [list(map(int, input().split())) for i in range(H)]

    if n == 0:
        print(x)
    else:
        P = list(map(int, input().split()))
        P.sort()
        #B = [i for i in range(102)]

        if x not in P:
            print(x)
        else:
            xindex = P.index(x)

            for j in range(1,100):
                if xindex - j >= 0:
                    if P[xindex - j] != x-j:
                        print(x-j)
                        break
                else:
                    print(x-j)
                if xindex + j <= n-1:
                    if P[xindex + j] != x+j:
                        print(x+j)
                        break
                else:
                    print(x+j)

resolve()

Submission status: Wrong Answer

Solution code:
x, n = map(int, input().split())
if n == 0:
    print(x)
    exit()
p = list(map(int, input().split()))
if x not in p:
    print(x)
    exit()

ans = 10**9
for i in range(1, n):
    if x-i not in p:
        ans = min(ans, i)
        print(x-i)
        break
    if x+i not in p:
        ans = min(ans, i)
        print(x+i)
        break

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

p=sorted([int(x) for x in input().split()])
a=[]
ans=10**9
for i in range(-1,101):
    if i in p:
        pass
    else:
        a.append([i,abs(x-i)])
        ans=min(ans,abs(x-i))
for i in range(len(a)):
    if a[i][1]==ans:
        print(a[i][0])
        sys.exit()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
X, N = map(int, input().split())
P =  set(map(int, input().split()))
Nums = set(range(1, 101))
Nums = Nums - P
sorted(Nums)


minNum = 99999
minIndex = 0
for n in Nums:
    if minNum == abs(X-n):
        break
    if abs(X - n)< minNum:
        minNum = abs(X - n)
        minIndex = n

print(minIndex)

Submission status: Wrong Answer

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

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


a = 0
for m in range(100 + 1):
    if m in p:
        continue
    else:
        if abs(x - a) > abs(x - m):
            a = m

print(a)

Submission status: Wrong Answer

Solution code:
x, n = map(int, input().split())
a = list(map(int, input().split()))
if (x not in a):
    print(x)
    exit()


tar1 = x
tar2 = x
ff1 = True
ff2 = True

while True:
    if (ff1 is True):
        tar1 -= 1
        if (tar1 not in a):
            print(tar1)
            exit()
        if (tar1 == 0):
            ff1 = False

    if (ff2 is True):
        tar2 += 1
        if (tar2 not in a):
            print(tar2)
            exit()
        if (tar2 == 100):
            ff2 = False

    if ((ff1 is False) and (ff2 is False)):
        break

Submission status: Wrong Answer

Solution code:
x,n = map(int,input().split())
if n == 0:
    print(x)
    exit()
p = list(map(int,input().split()))
t = list(range(-100,101))
u = set(t)-set(p)
u = list(u)
u.sort()
dif = 2**60
ans = 2**60
for a in u:
    tmp = abs(a-x)
    if dif > tmp:
        ans = a
        dif = tmp
    elif dif == tmp:
        if ans > a:
            ans = a
if x <= dif:
    ans = -(dif-x)
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np


def main(X, N, a):
    a.append(10000000000)
    a.append(-10000000000)
    a.sort()
    maxn = a[0]-1
    for i in range(len(a)-1):

        if a[i] >= X:
            if a[i+1]-a[i] > 1:
                maxn = a[i]+1
                break
            if X-maxn < a[i]-X:
                break
        else:
            if a[i+1]-a[i] > 1:
                if a[i+1] > X and a[i] < X:
                    maxn = X
                    break
                maxn = a[i+1]-1

    return maxn


X, N = map(int, input().split())
try:
    a = list(map(int, input().split()))
except:
    a = []
print(main(X, N, a))

Submission status: Wrong Answer

Solution code:
x,n=map(int,input().split())
if n!=0:
    y=100
    p=list(map(int,input().split()))
    for i in range(max(x,max(p))+1):
        if i not in p:
            if abs(x-i)<y:
                ans=i
                y=abs(x-i)
    print(ans)
            
    
    
    
    
else:
    print(x)

Submission status: Wrong Answer

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

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

for i in range(1,100):
    if not X-i in L:
        print(X-i)
        break
    if not X+i in L:
        print(X+i)
        break

Submission status: Wrong Answer

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

p = list(map(int, input().split()))
pp = set(p)
numlist = [i for i in range(-100, 101)]
numlistt = set(numlist)
newlist = numlistt - pp
newlistt = list(newlist)
newlisttt = newlistt.sort()
absn = 1000
ans = 1000

for i in newlistt:
    if absn > abs(X-i):
        if absn == abs(X-i):
            break
        else:
            ans = i
            absn = abs(X-i)

print(ans)

Submission status: Wrong Answer

Solution code:
x, n = map(int, input().split())
if n ==0:
    print(x)
    
else:
    p = list(map(int, input().split()))
    p.sort()
    #print(p)
    ans = 1000
    xx = 101
    for i in range(100):
        if not i in p:
            if x-i>=0 and ans>x-i:
                ans = x-i
                xx = i
            elif i-x>0 and ans>i-x:
                ans = i-x
                xx = i
    print(xx)

Submission status: Wrong Answer

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

if n == 0:
  print(x)
else:
  p = list(map(int, input().split()))
  p.sort()
  if not x in p:
    print(x)
  else:
    i = p.index(x)
    j = 0
    while True:
      j += 1
      if j % 2 == 0:
        k = j
      else:
        k = -j
      if i + k < 0 or i + k >= n:
        print(x + k)
        break
      if p[i + k] != x + k:
        print(x + k)
        break

Submission status: Wrong Answer

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

ans=1000
m=-1
if abs(x)<=abs(x-100):
    m=0
else:
    m=100
for i in range(100):
    if abs(x-ans)>abs(x-i) and i not in p:
        ans=i

if abs(x-ans)<abs(x-m):
    print(ans)
elif abs(x-ans)==abs(x-m):
    print(min(ans,m))
else:
    print(m)

Submission status: Wrong Answer

Solution code:
import sys



def main():
  X, N = list(map(int, input().split()));

  ans = X;
  min_value = 101

  if N == 0:
    print(ans)
  else:
    p = list(map(int, input().split()))
    a = [i for i in range(0, 101)]

    for v in p:
      a[v] = -1

    for i in range(0, 101):
      if a[i] != -1:
        d = abs(X - a[i])

        if(min_value > d):
          min_value = d
          ans = i

    print(ans);

if __name__ == '__main__':
  main()

Submission status: Wrong Answer

Solution code:
def main():
	x, n = map(int, input().split())
	P = list(map(int, input().split()))
	if n == 0:
		print(x)
		return
	ans = 0
	min_dis = 1000
	for item in range(101):
		if item in P:
			continue
		dis = abs(item - x)
		if min_dis > dis:
			min_dis = dis
			ans = item
	print(ans)
	return

if __name__ == "__main__":
	main()

Submission status: Wrong Answer

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

P = list(map(int, input().split()))
candidates = [i for i in range(101)]

ans = 1000
min_diff = 1000
for c in candidates:
    if c in P:
        continue
    diff = abs(X - c)
    if diff < min_diff:
        ans = c
        min_diff = diff

print(ans)

Submission status: Wrong Answer

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

hidden_L = [i+1 for i in range(100)]

for A_i in A_L:
    hidden_L.remove(A_i)

counter = 0

while True:
    minus = X - counter
    plus  = X + counter
    if minus < 0 or plus >100:
        break
    if minus in hidden_L:
        print(str(minus))
        break
    if plus in  hidden_L:
        print(str(plus))
        break
    counter = counter + 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()))

PP=sorted(P, reverse=True)
sab=abs(X-P[0])
#print(PP[0])
for i in range(N):
    if PP.count(X-i)==0 :
        print(X-i)
        sys.exit()
    if PP.count(X+i)==0:
        
        print(X+i)
        sys.exit()

Submission status: Wrong Answer

Solution code:
x, n = map(int, input().split())
ps = list(map(int, input().split()))
anss = [101] * 103
r = list(range(0, 101))
r.insert(0, -1)
for i in r:
  if (i not in ps):
    anss[i] = abs(x - i)
m = min(anss)
for i, ans in enumerate(anss):
  if ans == m:
    print(i)
    exit()

Submission status: Wrong Answer

Solution code:
X,N = map(int,input().split())
p = list(map(int,input().split()))
L = [i-100 for i in range(201)]
for item in p:
    L.pop(L.index(item))

MIN = 10**5
ans = 10**5
for item in L:
    if abs(item-X) < MIN:
        MIN = abs(item-X)
        ans = item

print(ans)

Submission status: Wrong Answer

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

c = [i for i in range(1,201)]
s = set(p)
d = set(c)-s
# print (d)

ans = [[] for i in range(200)]
for i in list(d):
  a = 0
  y = abs(i-x)
  ans[y].append(i)

for i in ans:
  if len(i) == 0:
    continue
  print (min(i))
  exit()

Submission status: Wrong Answer

Solution code:
X ,N = map(int,input().split())
P = list(map(int,input().split()))
if N == 0:
    print(X)
    exit(0)
A = list(range(0,102))
ans = 0
mins = 100


for a in A:
    if a not in P:
        if abs(a-X) < mins:
            mins = abs(a-X)
if X - mins:
    print(X-mins)
else:
    print(X+mins)

Submission status: Wrong Answer

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

result = 0
if N == 0:
    result = X
else:
    list = [i for i in range(101)]
    for i in P:
        list.remove(i)
    min = 100
    for i in list:
        if min > abs(X-i):
            min = abs(X - i)
            result = i

print(result)

Submission status: Wrong Answer

Solution code:
X, N = map(int, input().split())
if N == 0:
    print(X)
else:
    P = list(map(int, input().split()))
    for i in range(1,202):
        if (X-i) not in P:
            print(X-i)
            break
        elif (X+i) not in P:
            print(X+i)
            break
    else:
        print(X)

Submission status: Wrong Answer

Solution code:
import numpy as np

def resolve():
    x, n = map(int, input().split())
    if n == 0:
        print(x)
        return
    P = set(map(int, input().split()))
    if x not in P:
        print(x)
        return

    P_not = np.array(list(set(list(range(-1, 101))) - P))
    diff = np.abs(P_not - x)
    print(P_not[diff.argmin()])

resolve()

Submission status: Wrong Answer

Solution code:
X,N=map(int,input().split())
P = list(map(int,input().split()))
value = float('inf')
if(N==0):
    print(X)
    exit()
ans_value= 101
for i in range(0,101):
    if (i not in P):
        if(abs(X-i)<value):
            value=abs(X-i)
            ans_value=i
print(ans_value)

Submission status: Wrong Answer

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

for i in range(101):
    sub = x - i
    if sub > 0 and sub not in ps:
        print(sub)
        break

    add = x + i
    if add < 100 and add not in ps:
        print(add)
        break

Submission status: Wrong Answer

Solution code:
x, n = map(int, input().split())
if(n == 0):
    print(x)
elif(n == 1):
    if(n == x):
        print(x - 1)
    else:
        print(x)
else:
    p = list(map(int, input().split()))
    p.sort()
    p2 = map(lambda a: a - x, p)
    ps = sorted(p2, key=abs)
    q = list(range((-1) * n, n))
    qs = sorted(q, key=abs)
    for i in range(n):
        if(ps[i] != qs[i]):
            print(qs[i] + x)
            break

Submission status: Wrong Answer

Solution code:
x,n=map(int,input().split())
try:
  p=list(map(int,input().split()))
except:
  print(x)
  exit()
ans=float('inf')
for i in range(1,101):
  if i not in p:
    ans=min(ans,abs(x-i))
    
    
if x-ans not in p and (x-ans)>0 and (x-ans)<=x:
  print(x-ans)
  
elif x-ans not in p and (x-ans)<=x:
  print(x+ans)
else:
  print(x+ans)

Submission status: Wrong Answer

Solution code:
X,N = map(int,input().split())
if N > 0:
  p = list(map(int,input().split()))
a = 100
ans = 0
for i in range(-1,101):
  if N == 0:
    ans = X
    break
  if p.count(i) == 0 and a > abs(X - i):
    a = abs(X - i)
    ans = i
print(ans)

Submission status: Wrong Answer

Solution code:
X,N = map(int,input().split())
p = list(map(int,input().split()))
min1=[]
x_min = 100
num_list = list(range(101))
for i in range(N):
    num_list.remove(p[i])

for j in reversed(num_list):
    x = abs(j-X)
    if x_min >= x:
        x_min =  x
        close=j
print(close)

Submission status: Wrong Answer

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

check = float("inf")
ans = float("inf")
for p in range(100,0,-1):
    if p in p_lst:
        continue
    else:
        #print(p)
        if check >= abs(p-x):
            check = abs(p-x)
            ans = p
            
print(ans)

Submission status: Wrong Answer

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

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

if N == 0:
    print(X)
    exit()

diff = high = low = 0
while True:
    if X + diff not in P:
        high = X + diff
    if X - diff not in P:
        low = X - diff
    if high == 0 and low == 0:
        diff += 1
        continue

    if low == 0:
        print(high)
    else:
        print(low)
    break

Submission status: Wrong Answer

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

	diff_1 = abs(X-p[-1])
	diff_2 = abs(X-p[0])
	diff = max(diff_1,diff_2)

	for x in range(1,diff+1):
		if X-x not in p and X-x > p[0]:
			print(X-x)
			break
		if X+x not in p and X+x < p[-1]:
			print(X+x)
			break

Submission status: Wrong Answer

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

diff = [200, 0]

for i in range(1, 101):
    if i not in p_list:
        new_diff = abs(i - X)
        if new_diff < diff[0]:
            diff[0] = new_diff
            diff[1] = i

print(diff[1])

Submission status: Wrong Answer

Solution code:
import sys



def main():
  X, N = list(map(int, input().split()));

  ans = X;
  min_value = 101

  if N == 0:
    print(ans)
  else:
    p = list(map(int, input().split()))
    a = [i for i in range(0, 101)]

    for v in p:
      a[v] = -1

    for i in range(0, 101):
      if a[i] != -1:
        d = abs(X - a[i])

        if(min_value > d):
          min_value = d
          ans = i

  print(ans);

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()))
  s = sorted(p)

if(N == 0): 
  print(X)
else:
  j = 0
  #min=X-(-1)
  min = abs(X+1)
  ans = -1
  for i in range(1,101):
    if(i != s[j]):
      if(abs(X-i) < min):
        min = abs(X-i)
        ans = i
    else:
      j += 1
    if(j >= len(s)):j=0
  if(abs(X-101)<min):
    ans = 101
  print(ans)

Submission status: Wrong Answer

Solution code:
a, b = map(int, input().split())
if b == 0:
    print(a)
else:
    lis = list(map(int, input().split()))
    tt = [0] * 101
    for k in range(b):
        tt[lis[k]] = 1
    
    if tt[a] == 0:
        print(a)
        exit()
    for k in range(101):
        if a -k < 1:
            print(a-k)
            exit()
        elif a + k > 100:
            print(a+k)
            exit()
        else:
            if tt[a - k] == 0:
                print(a-k)
                exit()
            if tt[a + k] == 0:
                print(a+k)
                exit()

Submission status: Wrong Answer

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

ans = 10 ** 9
num = 10 ** 9
a = [0] * 200
for i in range(len(p)):
    a[p[i]] = 1

for i in range(101):
    if a[i] == 1:
        continue

    if ans > abs(i - x):
        num = i
        ans = abs(i - x)

# print(num)
if abs(x - (-1)) < abs(num-x):
    num = -1
print(num)

Submission status: Wrong Answer

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

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

flg = 1000
ans = 1000
m = max(P)
itera = list(range(m + 1))
itera.reverse()

for i in itera:
    if not i in P and flg > abs(X - i):
        flg = abs(X - i)
        ans = min(ans, i)

if ans == 1000:
    if abs(X - m - 1) <= X:
        ans = m + 1
    else:
        ans = 0

print(ans)

Submission status: Wrong Answer

Solution code:
x,n = map(int,input().split())
if n ==0:
  print(x)
  exit()
q = input().split()
p = sorted(abs(int(i)-x) for i in q)
for i in range(n):
    if i != p[i]:
        if x - i not in q:
            print(x - i)
        else:
            print(x + i)
        exit()

Submission status: Wrong Answer

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

  min = 1000
  ans = 0
  for i in range(102):
    if abs(x-i)!=0 and abs(x-i)<min and (i in p)==False:
      min = abs(x-i)
      ans = i

  print(ans)

Submission status: Wrong Answer

Solution code:
x,n = map(int, input().split())
v = list(map(int, input().split()))
for i in range(200):
    if x not in v:
        print(x)
        exit()
    else:
        if ((x - i) >= 0) and ((x - i) <= 100) and (x - i) not in v:
            print(x-i)
            exit()
        elif ((x + i) >= 0) and ((x + i) <= 100) and (x + i) not in v:
            print(x+i)
            exit()

Submission status: Wrong Answer

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



#print(plist)
l=list(range(-1,101))

if N >0:
    plist=list(map(int,input().split()))

    for i in range(len(plist)):
        l.remove(plist[i])


#print(l)
ans=[]
for i in range(len(l)):
    ans.append(abs(l[i]-X))

print(l[ans.index(min(ans))])

Submission status: Wrong Answer

Solution code:
# coding:utf-8


def main():
    X, N = map(int, input().split())
    if (N > 0):
        P = list(map(int, input().split()))
        P_list = sorted(P)
        ans = X
        temp = X
        for pi in range(1, 101):
            n = abs(pi - X)
            if n < temp and pi != X and not pi in P_list:
                ans = pi
                temp = n
            elif n == temp and pi != X and not pi in P_list and pi < ans:
                ans = pi
                temp = n

        print(ans)

    else:
        print(X)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
from sys import stdin
import sys
import math
import random
from decimal import Decimal


X, N = [int(x) for x in stdin.readline().rstrip().split()]
if N == 0:
    print(X)
    sys.exit()
p = list(map(int, input().split()))

ans = 10**9
ans1 = [0, 10**9]
for i in range(-100, 101):
    if i not in p:

        if ans > abs(X-i):
            ans = X-i
            # print(i, abs(X-i))
            if ans1[1] == abs(X-i):
                pass
            else:
                ans1[0] = i
            # ans1[1] = abs(X-i)
            # if ans1 > i:
            #     ans1 = i
                # print(i)
print(ans1[0])

Submission status: Wrong Answer

Solution code:
X,N=map(int,input().split())
if N==0:
	print(X)
	exit()
p=list(map(int,input().split()))
if X not in p:
	print(X)
	exit()
tmp=100000
for i in range(101):
	if i in p:
		continue
	if tmp>abs(X-i):
		ans=i
		tmp=abs(X-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(50):
    u_flg = False
    l_flg = False

    x_u=x+i
    x_l=x-i
    for p in P:
        if x_u == p:
            u_flg = True
        if x_l == p:
            l_flg = True

    if u_flg == False and l_flg == False:
        print(min(x_u,x_l))
        break
    elif u_flg == False:
        print(x_u)
        break
    elif l_flg == False:
        print(x_l)
        break

Submission status: Wrong Answer

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

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

p_li = list(map(int, input().split()))
p_li.sort()

ans = 999
for i in range(101):
    if not i in p_li:
        tmp = i

        if abs(x - ans) > abs(x - tmp):
            ans = i

print(ans)

Submission status: Wrong Answer

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

a,b=x,x

ans=0
while ans==0:
  if n==0:
    ans=x
  else:
    a=a-1
    b=b+1
    if a not in lis:
      ans=a
      break
    if b not in lis:
      ans=b

print(ans)

Submission status: Wrong Answer

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

if N==0:
    print(X)
    exit()

p = list(map(int,input().split()))
q = [i for i in range(-100,101)]
li = set(p) ^ set(q)
tmp = 1
ans = 0
while(1):
    if X-tmp in li:
        ans = X-tmp
        break
    elif X+tmp in li:
        ans = X+tmp
        break
    tmp += 1
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
X, N = map(int, input().split())
if (N==0):
    print(X)
    sys.exit()
elif(N==100):
    if(X<51):
        print(0)
        sys.exit()
    else:
        print(101)
        sys.exit()
p = list(map(int, input().split()))

n_ans = 1
sa = 100
for k in range(0,102,1):
    if (k in p):
        continue
    if(abs(k-X) < sa):
        n_ans = k
        sa = abs(k-X)
    else:
        break
print(n_ans)

Submission status: Wrong Answer

Solution code:
x, n = map(int, input().split())
p = []
try:
  while True:
    p = list(map(int, input().split()))
except EOFError:
    pass

a = 1
ans = ''
while ans == '':
  if len(p) == 0:
    ans = x
    break
  elif x - a not in p:
    ans = x - a
    break
  elif x + a not in p:
    ans = x + a
    break
  a += 1
print(ans)

Submission status: Wrong Answer

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

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

for i in range(1,X):
    if not X-i in L:
        print(X-i)
        break
    if not X+i in L:
        print(X+i)
        break

Submission status: Wrong Answer

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

result = 100
AAA = result

if N == 0:
    result = X
else:
    for pi in range(1,101):
        if pi in P:
            continue

        if pi > X:

            if abs(X - AAA) <= abs(X - pi):
                result = AAA
            else:
                result = pi

            break

        AAA = pi

print(result)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
X, N = [int(s) for s in input().split()]
if N == 0:
    print(X)
    exit()
P = [int(s) for s in input().split()]
Y = list(range(1, 120))
for a in sorted(map(lambda x: (abs(x - X), x), Y), key=lambda x: [x[0], x[1]]):
    if a[0] != 0 and not a[1] in P:
        print(a[1])
        exit()

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np
x, n = map(int, input().split())
if n == 0:
    print(x)
    sys.exit()
p = np.array([int(i) for i in input().split()])
a = (p - x)
for i in range(101):
    if i not in a:
        if i == 0:
            print(x)
            sys.exit()
        else:
            if x - i not in p:
                print(x - i)
                sys.exit()
            else:
                print(x + i)
                sys.exit()

Submission status: Wrong Answer

Solution code:
import sys

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

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

min_abs = 101
min_e = 0
for i in p[1:]:
  if abs(x-i) < min_abs:
    min_abs = abs(x-i)
    min_e = i

for i in range(1, int(len(p)/2)):
  if min_e - i not in p:
    print(min_e - i)
    break
  if min_e + i not in p:
    print(min_e + i)
    break

Submission status: Wrong Answer

Solution code:
import sys


def main():
    X, N = list(map(int, input().split()))
    ans = 101
    dis = abs(ans - X)
    if N == 0:
        print(X)
        sys.exit()
    P = list(map(int, input().split()))
    for i in range(0, 101):
        if i not in P:
            if dis > abs(i - X):
                dis = abs(i - X)
                ans = i
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
n,m=[int(n) for n in input().split()]
arr=list(map(int,input().strip().split()))
if(m==0):
    print(n)
else:
    j=n
    s1=205
    while(j>=1):
        flag=0
        for i in range(m):
            if(arr[i]==j):
                flag=1
        if(flag==1):
            j=j-1
        else:
            s1=j
            break
    j=n
    s2=206
    while(j<101):
        flag=0
        for i in range(m):
            if(arr[i]==j):
                flag=1
        if(flag==1):
            j=j+1
        else:
            s2=j
            break
    a=abs(n-s1)
    b=abs(n-s2)
    if(a<=b and a<102):
        print(s1)
    elif(a>b and b<102):
        print(s2)
    else:
        print(0)

Submission status: Wrong Answer

Solution code:
x,n=map(int,input().split())
if n==0:
    print(x)
    exit()
elif n==100:
    print(-1)
    exit()
List=list(map(int,input().split()))
num=list(range(-1000,1000))
min_num=1000000000
for i in range(len(List)):
    if num.count(List[i])>=1:
        num.remove(List[i])
for i in range(len(num)):
    if (abs(num[i]-x)<abs(min_num-x)) or (abs(num[i]-x)==abs(min_num-x) and num[i]<min_num):
        min_num=num[i]
print(min_num)

Submission status: Wrong Answer

Solution code:
def main():
	x, n = map(int, input().split())
	P = list(map(int, input().split()))
	ans = 0
	min_dis = 1000
	for item in range(101):
		if item in P:
			continue
		dis = abs(item - x)
		if min_dis > dis:
			min_dis = dis
			ans = item
	print(ans)
	return

if __name__ == "__main__":
	main()

Submission status: Wrong Answer

Solution code:


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

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

an = [0]*101

an[x]=-1 if n != 0 else 0

for pi in pn:
    an[pi] = -1


dist = 10000
ans = 99999
for i, ai in enumerate(an):
    if ai == -1:
        continue

    if dist > abs(i-x):
        dist = abs(i-x)
        ans = i


print(ans)

Submission status: Wrong Answer

Solution code:
X,N=map(int,input().split())
p=list(map(int,input().split()))
if N==0:
  print(X)
else:
  for i in range(0,X+1):
    if abs(X-i) not in p or abs(X+i) not in p:
      print(min([X-i,X+i]))
      break

Submission status: Wrong Answer

Solution code:
x, n=map(int, input().split())
if n==0:
    print(x)
    exit()
else:
    dic=list(map(int, input().split()))

if x not in dic:
    print(n)
else:
    for i in range(1, 101):
        a=x-i
        b=x+i
        if a not in dic and b not in dic:
            print(min(a,b))
            exit()
        if a not in dic:
            print(a)
            exit()
        if b not in dic:
            print(b)
            exit()

Submission status: Wrong Answer

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

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

if N == 0:
    print(X)
    exit()

diff = high = low = 0
while True:
    if X + diff not in P:
        high = X + diff
    if X - diff not in P:
        low = X - diff
    if high == low:
        diff += 1
        continue

    if low == 0:
        print(high)
    else:
        print(low)
    break

Submission status: Wrong Answer

Solution code:
n = input().split()
X = int(n[0])
N = int(n[1])

try:
    n2 = input()
except:
    pass

if N == 0:
    print(X)

else:
    n2 = n2.split()
    p = [int(item) for item in n2]

    for i in range(101):
        if i == 0:
            continue
        tmp = []

        if (X + i not in p ):
            tmp.append(X + i)

        if (X - i not in p ):
            tmp.append(X - i)
    
        if len(tmp)!=0:
            print(min(tmp))
            break