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())
l = list(map(int,input().split()))
l.sort()

nl = [0] * 102
nl[0] = 999
nl[101] = 999

for i in l:
    nl[i] = i

if(not(n == 0) and not(n == 100)):
    mx = x
    if(mx <= 100):
        for i in range(mx,len(nl)):
            if nl[i] == 0:
                mx = i
                break
            else:
                mx = 999
    else:
        mx = 999

    mi = x
    if(mi >= 1):
        for i in range(mi,-1,-1):
            if(nl[i] == 0):
                mi = i
                break
            else:
                mi = 999
    else:
        mi = 999

    if(abs(x - mi) > abs(x - mx)):
        print(mx)
    elif(abs(x - mi) == abs(x - mx)):
        print(min(mi,mx))
    else:
        print(mi)
elif(n == 100):
    print(0)
else:
    print(x)

Submission status: Wrong Answer

Solution code:
import sys
x, n = map(int, input(). split())
l = [0]*n
m = [0]*102
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, 102):
    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 = [int(i) for i in input().split()]
if N == 0:
# if False:
    print(X)
else:
    Ps = set([int(i) for i in input().split()])

    # 間違い。なぜ...？？？
    if X not in Ps:
        print(X)

    # print(f'{X} {sorted(Ps)}')
    diff = 0
    while True:
        a = X - diff
        if a not in Ps:
            print(a)
            break
        a = X + diff
        if a not in Ps:
            print(a)
            break
        diff += 1

Submission status: Wrong Answer

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

p = input().split(' ')
p =[int(i) for i in p]
if X not in p:
    print(X)
    exit()

num_list = [int(i-99) for i in range(200)]
[num_list.remove(p[i]) for i in range(N)]
tmp = [0] * int(len(num_list))


for i in range(len(num_list)):
    tmp[i] = max(num_list[i], X) - min(num_list[i], X)

ans = [i for i,x in enumerate(tmp) if x == min(tmp)]
# print(num_list)
# print(tmp)
# print(ans)
if len(ans) == 2:
    print(min(num_list[ans[0]],num_list[ans[1]]))
else:
    print(num_list[ans[0]])

Submission status: Wrong Answer

Solution code:
X, N = [int(i) for i in input().split()]
# if N == 0:
if False:
    print(X)
else:
    Ps = set([int(i) for i in input().split()])
    if not X in Ps:
        print(X)

    # print(f'{X} {sorted(Ps)}')
    diff = 0
    while True:
        a = X - diff
        if a not in Ps:
            print(a)
            break
        a = X + diff
        if a not in Ps:
            print(a)
            break
        diff += 1

Submission status: Wrong Answer

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

p = input().split(' ')
p =[int(i) for i in p]
if X not in p:
    print(X)
    exit()

num_list = [int(i-99) for i in range(200)]
[num_list.remove(p[i]) for i in range(N)]
tmp = [0] * int(len(num_list))


for i in range(len(num_list)):
    tmp[i] = max(num_list[i], X) - min(num_list[i], X)

ans = [i for i,x in enumerate(tmp) if x == min(tmp)]
# print(num_list)
# print(tmp)
print(ans)
if len(ans) == 2:
    print(min(num_list[ans[0]],num_list[ans[1]]))
else:
    print(num_list[ans[0]])

Submission status: Wrong Answer

Solution code:
X, N = [int(i) for i in input().split()]
if N == 0:
    print(X)
else:
    Ps = set([int(i) for i in input().split()])
    if not X in Ps:
        print(X)

    # print(f'{X} {sorted(Ps)}')
    diff = 0
    while True:
        a = X - diff
        if a not in Ps:
            print(a)
            break
        a = X + diff
        if a not in Ps:
            print(a)
            break
        diff += 1

Submission status: Wrong Answer

Solution code:
X, N = [int(i) for i in input().split()]
if N == 0:
    print(X)
else:
    Ps = set([int(i) for i in input().split()])
    if not X in Ps:
        print(X)

    # print(f'{X} {sorted(Ps)}')
    diff = 0
    while True:
        a = X - diff
        if not a in Ps:
            print(a)
            break
        a = X + diff
        if not a in Ps:
            print(a)
            break
        diff += 1

Submission status: Wrong Answer

Solution code:
X,N = (int(i) for i in input().split())
p_list=[int(i) for i in input().split()]
for i in range(1,200):
    if p_list==[]:
        print(str(X))
        break
    if i%2==1:
        X-=i
        if X<0:
            continue
        if X>100:
            continue
        if X not in p_list:
            print(str(X))
            break
    elif i%2==0:
        X+=i
        if X<0:
            continue
        if X>100:
            continue
        if X not in p_list:
            print(str(X))
            break

Submission status: Wrong Answer

Solution code:
X,N = (int(i) for i in input().split())
p_list=[int(i) for i in input().split()]
for i in range(1,200):
    if p_list==[]:
        print(str(X))
        break
    if i%2==1:
        X-=i
        if X<0:
            print(str(0))
            break
        if X>100:
            print(str(100))
            break
        if X not in p_list:
            print(str(X))
            break
    elif i%2==0:
        X+=i
        if X<0:
            print(str(0))
            break
        if X>100:
            print(str(100))
            break
        if X not in p_list:
            print(str(X))
            break

Submission status: Wrong Answer

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

p = input().split(' ')
p =[int(i) for i in p]
if X not in p:
    print(X)
    exit()

num_list = [int(i-99) for i in range(200)]
[num_list.remove(p[i]) for i in range(N)]
tmp = [0] * int(len(num_list))


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

ans = tmp.index(min(tmp))
# print(num_list)
# print(ans)
print(num_list[ans])

Submission status: Wrong Answer

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

p = input().split(' ')
p =[int(i) for i in p]
num_list = [int(i-99) for i in range(200)]
[num_list.remove(p[i]) for i in range(N)]
tmp = [0] * int(len(num_list))


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

ans = tmp.index(min(tmp))
# print(num_list)
# print(ans)
print(num_list[ans])

Submission status: Wrong Answer

Solution code:
X,N = (int(i) for i in input().split())
p_list=[int(i) for i in input().split()]
for i in range(1,200):
    if p_list==[]:
        print(str(X))
        break
    if i%2==1:
        X-=i
        if X not in p_list:
            print(str(X))
            break
    elif i%2==0:
        X+=i
        if X not in p_list:
            print(str(X))
            break
    if X<0:
        print(str(0))
        break
    if X>100:
        print(str(100))
        break

Submission status: Wrong Answer

Solution code:
X, N = [int(i) for i in input().split()]
if N == 0:
    print(X)
else:
    Ps = set([int(i) for i in input().split()])
    if not X in Ps:
        print(X)

    # print(f'{X} {sorted(Ps)}')
    diff = 0
    while True:
        if not X - diff in Ps:
            print(X - diff)
            break
        if not X + diff in Ps:
            print(X + diff)
            break
        diff += 1

Submission status: Wrong Answer

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

ans = 100
d = 1000

for i in range(100, -1, -1):
  if (i not in p) and abs(i-x) <= d:
    d = abs(i-x)
    ans = i

print(ans)

Submission status: Wrong Answer

Solution code:
X, N = [int(i) for i in input().split()]
if N == 0:
    print(X)
else:
    Ps = set([int(i) for i in input().split()])
    if not X in Ps:
        print(X)

    print(f'{X} {sorted(Ps)}')
    diff = 0
    while True:
        if not X - diff in Ps:
            print(X - diff)
            break
        if not X + diff in Ps:
            print(X + diff)
            break
        diff += 1

Submission status: Wrong Answer

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

ans = -1
d = 1000

for i in range(100, -1, -1):
  if (i not in p) and abs(i-x) < d:
    d = abs(i-x)
    ans = i

print(ans)

Submission status: Wrong Answer

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

nl = [0] * 102
nl[0] = 999
nl[101] = 999

for i in l:
    nl[i] = i

if(not n == 0):
    mx = x
    if(mx <= 100):
        for i in range(mx,len(nl)):
            if nl[i] == 0:
                mx = i
                break
            else:
                mx = 999
    else:
        mx = 999

    mi = x
    if(mi >= 1):
        for i in range(mi,-1,-1):
            if(nl[i] == 0):
                mi = i
                break
            else:
                mi = 999
    else:
        mi = 999

    if(abs(x - mi) > abs(x - mx)):
        print(mx)
    elif(abs(x - mi) == abs(x - mx)):
        print(min(mi,mx))
    else:
        print(mi)
else:
    print(x)

Submission status: Wrong Answer

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

ans = 0
d = 101

for i in range(101):
  if (i not in p) and abs(i-x) < d:
    d = abs(i-x)
    ans = i

print(ans)

Submission status: Wrong Answer

Solution code:
#C

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

nl = [0] * 102
nl[0] = 999
nl[101] = 999

for i in l:
    nl[i] = i

if(not n == 0):
    mx = x + 1
    if(mx <= 100):
        for i in range(mx,len(nl)):
            if nl[i] == 0:
                mx = i
                break
            else:
                mx = 999
    else:
        mx = 999

    mi = x - 1
    if(mi >= 1):
        for i in range(mi,-1,-1):
            if(nl[i] == 0):
                mi = i
                break
            else:
                mi = 999
    else:
        mi = 999

    if(abs(x - mi) > abs(x - mx)):
        print(mx)
    elif(abs(x - mi) == abs(x - mx)):
        print(min(mi,mx))
    else:
        print(mi)
else:
    print(x)

Submission status: Wrong Answer

Solution code:
from typing import List


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

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

    p_lst: List[int] = list(map(int, input().split()))

    for i in range(50):
        if X - i not in p_lst:
            print(X - i)
            exit()
        if X + i not in p_lst:
            print(X + i)
            exit()


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
X,N = (int(i) for i in input().split())
p_list=[int(i) for i in input().split()]
for i in range(1,200):
    if p_list==[]:
        print(str(X))
        break
    if i%2==1:
        X-=i
        if X not in p_list:
            print(str(X))
            break
    elif i%2==0:
        X+=i
        if X not in p_list:
            print(str(X))
            break

Submission status: Wrong Answer

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

p = set(p)
if n == 0:
    print(x)
    
else:
    _x = x 
    x_ = x
    while True:
        _x -= 1
        x_ += 1
        if _x not in p:
            print(_x)
            break
        if x_ not in p:
            print(x_)
            break

Submission status: Wrong Answer

Solution code:
import numpy as np
lis=[]
for i in range(102):
    lis.append(i)
print(lis)
listA=[]
while True:
    try:
        listA.append(list(map(int,input().split())))
    except:
        break;
print(listA)
 
X_=listA[0]
X=X_[0]
N=X_[1]
if N!=0:
    P =listA[1]
 
    arr = np.array(lis)
    P_max = max(P)
    P_min = min(P)-1
    arr=arr[arr<=P_max+1]
    arr=arr[arr>=P_min-1]
    lis=arr.tolist()
    for p in P:
        lis.remove(p)
    print(lis)
    lis_=[]
    for l in lis:
        lis_.append(abs(l-X))
    print(lis_)
    lis_min=min(lis_)
 
    def my_index(l, x, default=False):
        if x in l:
            return l.index(x)
        else:
            return default
 
    print(lis[my_index(lis_, lis_min)])
else:
    print(X)

Submission status: Wrong Answer

Solution code:
X,N = (int(i) for i in input().split())
p_list=[int(i) for i in input().split()]
for i in range(1,100):
    if p_list==[]:
        print(str(X))
        break
    if (X<1|X>100):
        print(str(X))
        break
    if i%2==1:
        X-=i
        if X not in p_list:
            print(str(X))
            break
    elif i%2==0:
        X+=i
        if X not in p_list:
            print(str(X))
            break

Submission status: Wrong Answer

Solution code:
import numpy as np
lis=[]
for i in range(102):
    lis.append(i)

listA=[]
while True:
    try:
        listA.append(list(map(int,input().split())))
    except:
        break;
#print(listA)
 
X_=listA[0]
X=X_[0]
N=X_[1]
if N!=0:
    P =listA[1]
 
    arr = np.array(lis)
    P_max = max(P)
    P_min = min(P)-1
    arr=arr[arr<=P_max]
    arr=arr[arr>=P_min]
    lis=arr.tolist()
    for p in P:
        lis.remove(p)
    #print(lis)
    lis_=[]
    for l in lis:
        lis_.append(abs(l-X))
    #print(lis_)
    lis_min=min(lis_)
 
    def my_index(l, x, default=False):
        if x in l:
            return l.index(x)
        else:
            return default
 
    print(lis[my_index(lis_, lis_min)])
else:
    print(X)

Submission status: Wrong Answer

Solution code:

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

if n == 0:
    print(x)
    
else:
    _x = x 
    x_ = x
    while True:
        _x -= 1
        x_ += 1
        if _x not in p:
            print(_x)
            break
        if x_ not in p:
            print(x_)
            break

Submission status: Wrong Answer

Solution code:
X,N = (int(i) for i in input().split())
p_list=[int(i) for i in input().split()]
for i in range(1,100):
    if p_list==[]:
        print(str(X))
        break
    if i%2==1:
        X-=i
        if X not in p_list:
            print(str(X))
            break
    if i%2==0:
        X+=i
        if X not in p_list:
            print(str(X))
            break

Submission status: Wrong Answer

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

if n == 0:
    print(x)
    
else:
    _x = x 
    x_ = x
    while True:
        _x -= 1
        x_ += 1
        if _x not in p:
            print(_x)
            break
        elif x_ not in p:
            print(x_)
            break

Submission status: Wrong Answer

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

if n == 0:
    print(x)
    
else:
    _x = x_ = x
    while True:
        _x -= 1
        x_ += 1
        if _x not in p:
            print(_x)
            break
        elif x_ not in p:
            print(x_)
            break

Submission status: Wrong Answer

Solution code:
x,n=map(int,input().split())
if n==0:
  print(x)
else:
  a=list(map(int,input().split()))
  ans=-1
  for i in range(1,101):
    if i not in a and abs(i-x)<abs(ans-x):
      ans=i
  print(ans)

Submission status: Wrong Answer

Solution code:
import sys

x,n = map(int, input().split())
p = sorted(list(map(int, input().split())))
res = [x,-1]
for i in range(101):
    a = x - i
    b = x + i
    if a not in p:
        print(a)
        sys.exit()
    if b not in p:
        print(b)
        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:
    q = []
    x_ = x
    _x = x
    for i in range(1, 101):
        if not i in p:
            q.append(i)
    while True:
        if _x - 1 in q:
            print(_x - 1)
            break
        elif x_ + 1in q:
            print(x_ + 1)
            break

Submission status: Wrong Answer

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

if n == 0:
    print(x)
else:
    q = []
    x_ = x
    _x = x
    for i in range(1, 101):
        if not i in p:
            q.append(i)
    while True:
        _x -= 1
        x_ += 1
        if _x in q:
            print(_x)
            break
        elif x_ in q:
            print(x_)
            break
        else:
            pass

Submission status: Wrong Answer

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

all = set(range(0, 101))
kouho = all - set(P)

min_dis = 200
for i in kouho:
    dis = abs(i-X)
    if min_dis > dis:
        min_i = i
        min_dis = dis

print(min_i)

Submission status: Wrong Answer

Solution code:
def main():
    X, N = map(int, input().split())
    P = list(map(int, input().split()))
    if N == 0:
        print(0)
        return
    diff = 100
    ans = -1
    for i in range(102):
        if i in P:
            continue
        d = abs(i - X)
        if d < diff:
            diff = d
            ans = i
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
x,n=map(int,input().split())
l=list(map(int,input().split()))#len of n
if x not in l:
    print(x)
elif n==0:
    print(x)
else:
    a=101
    for i in range(102):
        if i not in l:
            if abs(x-i)<abs(a-x):
                a=i
    print(a)

Submission status: Wrong Answer

Solution code:
x,n=map(int,input().split())
l=list(map(int,input().split()))#len of n
if x not in l:
    print(x)
elif n==0:
    print(x)
else:
    a=101
    for i in range(101):
        if i not in l:
            if abs(x-i)<abs(a-x):
                a=i
    print(a)

Submission status: Wrong Answer

Solution code:
x, n = map(int, input().split())
p = sorted(list(map(int, input().split())))
a=0
if n == 0:
  a=x
else:
  for i in p:
    if abs(a-x) > abs(i-x):
      a=i
print(a)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
x,n = map(int,input().split())
p = list(map(int,input().split()))
ans = []
for i in range(100):
    if i not in p:
        ans.append([abs(i - x),i])
ans.sort()
print(ans[0][1])

Submission status: Wrong Answer

Solution code:
def main():
    X, N = map(int, input().split())
    P = sorted(list(map(int, input().split())))
    if N == 0:
        print(0)
        return
    diff = 100
    ans = -1
    for i in range(100):
        if i in P:
            continue
        d = abs(i - X)
        if d < diff:
            diff = d
            ans = i
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
x, n = map(int, input().split())
p = sorted(list(map(int, input().split())))
a=0
if n == 0:
  a=x
else:
  for i in p:
    if abs(a-x) < abs(i-x):
      a=i
print(a)

Submission status: Wrong Answer

Solution code:
x,n = map(int, input().split())
if n == 0:
  print(x)
else:
  l = list(map(lambda t : int(t)-x, input().split()))
  p = [0] + sorted(map(abs,l)) + [n]
  for i in range((n+2)//2):
    if ( n == 2 * i +1 ) or ( p[2*i+1] != i ):
      if -i in l:
        print(x+i)
      else:
        print(x-i)
      break

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import itertools
from decimal import *

input = sys.stdin.readline

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
def inputStr(): return input()[:-1]

inf = float('inf')
mod = 1000000007

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-

def main():
	X,N = inputMap()
	p = inputList()

	sa = inf
	pointer = 0
	for i in range(100,0,-1):
		if i in p:
			continue
		tmp = abs(X-i)
		if tmp <= sa:
			sa = tmp
			pointer = i

	if sa == inf:
		if X > 50:
			print(101)
		else:
			print(0)
	else:
		print(pointer)


#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
if __name__ == "__main__":
	main()

Submission status: Wrong Answer

Solution code:
x,n = map(int,input().split())
if n == 0:
    print(x);exit(0)
*p, = sorted(map(int,input().split()))
pp = set(p)
ans = 9e9
for i in range(0,101):
    if i in pp: continue
    dis = abs(i-x)
    if dis < ans:
        xx = i
        ans = dis
    else:
        break
print(xx)

Submission status: Wrong Answer

Solution code:
X,N = map(int,input().split())
n = list(map(int,input().split()))
xn = list(range(1,101))
answer = 0
for i in range(N):
  xn.remove(n[i])
mindis = 100
for i in range(len(xn)):
  dis = abs(X-xn[i])
  if dis < mindis:
    mindis = dis
    answer = xn[i]
if N == 100:
  if X > 50:
    answer = 101
print(answer)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import itertools
from decimal import *

input = sys.stdin.readline

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
def inputStr(): return input()[:-1]

inf = float('inf')
mod = 1000000007

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-

def main():
	X,N = inputMap()
	p = inputList()

	sa = inf
	pointer = 0
	for i in range(100,0,-1):
		if i in p:
			continue
		tmp = abs(X-i)
		if tmp <= sa:
			sa = tmp
			pointer = i

	if sa == inf:
		print(101)
	else:
		print(pointer)


#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
if __name__ == "__main__":
	main()

Submission status: Wrong Answer

Solution code:
x,n = map(int, input().split())
if n == 0:
  print(x)
else:
  l = list(map(lambda t : int(t)-x, input().split()))
  p = [0] + sorted(map(abs,l))
  for i in range((n+1)//2):
    if ( n == 2 * i +1 ) or ( p[2*i+1] != i ):
      if -i in l:
        print(x+i)
      else:
        print(x-i)
      break

Submission status: Wrong Answer

Solution code:
x,n=map(int,input().split())
if n==0:
  print(x)
else:
  a=list(map(int,input().split()))
  ans=-1
  for i in range(0,101):
    if i not in a and abs(i-x)<abs(ans-x):
      ans=i
  print(ans)

Submission status: Wrong Answer

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

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

if x <= 50:
    minp = x
    minv = 0
    p.sort()
else:
    minp = abs(101 - x)
    minv = 101
    p.sort(reverse=True)

if n == 0:
    print(x)
elif n == 100:
    if x <= abs(101 - x):
        print(0)
    else:
        print(101)
else:
    for i in range(1, 101):
        if i in p:
            continue
        else:
            if abs(i - x) < minp:
                minp = abs(i - x)
                minv = i
    print(minv)

Submission status: Wrong Answer

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

    ans = min(
        (i for i in range(0, 101) if i not in P),
        key=lambda x: abs(X - x)
    )
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from math import ceil

X, N = [int(x) for x in input().split()]
l = [int(x) for x in input().split()]
l2 = [abs(int(x)-X) for x in l]
l2.sort()
t = 0
for i in range(N):
    if ceil(i/2) != l2[i]:
        t = ceil(i/2)
        break
if X - t in l:
    print(X + t)
else:
    print(X - t)

Submission status: Wrong Answer

Solution code:
X, N = map(int, input().split())
line = list(map(int, input().split()))
notLine = [i for i in range(-100, 201) if i not in line]
left = -1
right = len(notLine)
while abs(right - left) > 1:
    middle = (right + left) // 2
    if notLine[middle] >= X:
        right = middle
    else:
        left = middle
print(notLine[left], notLine[right])
if X - notLine[left] <= notLine[right] - X:
    print(notLine[left])
else:
    print(notLine[right])

Submission status: Wrong Answer

Solution code:
def forbidden_list():
    condition = input()
    num_str = input()
    
    condition_list = condition.split()
    X = int(condition_list[0])
    N = int(condition_list[1])
    
    if N == 0:
        print(X)
        return
    
    num_list_str = num_str.split()
    num_list = []
    for i in num_list_str:
        num_list.append(int(i))
    
    num_list.sort()
    flag = True
    sub = 0
    tmp = X
    
    while flag:
        tmp = X + sub
        for i in num_list:
            count = 0
            if tmp == i:
                count = 1
                break
        if count == 0:
            print(tmp)
            return
        
        sub += 1
        tmp = X - sub
        print(tmp)
        for i in num_list:
            count = 0
            if tmp == i:
                count = 1
                break
        if count == 0:
            print(tmp)
            return
    
forbidden_list()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import itertools
from decimal import *

input = sys.stdin.readline

def inputInt(): return int(input())
def inputMap(): return map(int, input().split())
def inputList(): return list(map(int, input().split()))
def inputStr(): return input()[:-1]

inf = float('inf')
mod = 1000000007

#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-

def main():
	X,N = inputMap()
	p = inputList()

	ans = inf
	pointer = 0
	for i in range(100,0,-1):
		if i in p:
			continue
		tmp = abs(X-i)
		if tmp <= ans:
			ans = tmp
			pointer = i

	print(pointer)


#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
#-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-
if __name__ == "__main__":
	main()

Submission status: Wrong Answer

Solution code:
x,n = map(int, input().split())
if n == 0:
  print(x)
else:
  l = list(map(lambda t : int(t)-x, input().split()))
  p = [0] + sorted(map(abs,l))
  for i in range(n//2):
    if ( n == 2 * i +1 ) or ( not ( p[2*i+1] == i )):
      if -i in l:
        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 x <= 50:
    minp = x
    minv = 0
    p.sort()
else:
    minp = abs(101 - x)
    minv = 101
    p.sort(reverse=True)

if n == 0:
    print(x)
elif n == 100:
    if x <= abs(101 - x):
        print(0)
    else:
        print(101)
else:
    for i in range(1, 101):
        if i in p:
            continue
        else:
            if abs(i - x) < minp:
                minp = abs(i - x)
                minv = i
            else:
                break
    print(minv)

Submission status: Wrong Answer

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

not_in_p = []
for i in range(0, 102):
    if i not in p:
        not_in_p.append(abs(x-i))
    else:
        not_in_p.append(102)

address = not_in_p.index(min(not_in_p))
print(not_in_p[address])

Submission status: Wrong Answer

Solution code:
def forbidden_list():
    condition = input()
    num_str = input()
    
    condition_list = condition.split()
    X = int(condition_list[0])
    N = int(condition_list[1])
    
    if N == 0:
        print(X)
        return
    
    num_list_str = num_str.split()
    num_list = []
    for i in num_list_str:
        num_list.append(int(i))
    
    num_list.sort()
    flag = True
    sub = 0
    tmp = X
    
    while flag:
        tmp = X + sub
        for i in num_list:
            count = 0
            if tmp == i:
                count = 1
                break
        if count == 0:
            print(tmp)
            return
        
        sub += 1
        tmp = X - sub
        for i in num_list:
            count = 0
            if tmp != i:
                count = 1
                break
        if count == 0:
            print(tmp)
            return
    
forbidden_list()

Submission status: Wrong Answer

Solution code:
x, n = map(int, input().split())
arr = sorted(list(map(int, input().split())))
mins = 10000
idx = 0
for i in range(1, 101):
    if abs(i-x) < mins and i not in arr:
        mins = abs(i-x)
        idx = i
print(idx)

Submission status: Wrong Answer

Solution code:
a = list(map(int, input().split()))
if a[1] == 0:
    print(a[0])
else:
    b = list(map(int, input().split()))
    c = []
    out = 0
    res = 10000001
    for i in range(101):
        if i not in b:
            c.append(i)
    for j in c:
        if (abs(j - a[0]) < res):
            res = abs(j - a[0])
            out = j
    print(out)

Submission status: Wrong Answer

Solution code:
x,n = map(int, input().split())
l = list(map(lambda t : int(t)-x, input().split()))
p = [0] + sorted(map(abs,l))
for i in range(n//2):
  if ( n == 2 * i +1 ) or ( not ( p[2*i+1] == i )):
    if -i in l:
      print(x+i)
    else:
      print(x-i)
    break

Submission status: Wrong Answer

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

not_in_p = []
for i in range(0, 102):
    if i not in p:
        not_in_p.append(i)
    else:
        not_in_p.append(102)

address = not_in_p.index(min(not_in_p))
print(not_in_p[address])

Submission status: Wrong Answer

Solution code:
x,n=map(int,input().split())
l=list(map(int,input().split()))
s=set()
p=x
res=0
while(True):
  if(not(p in l)):
    res=p
    break
  p-=1
s.add(res)
while(True):
  if(not(x in l)):
    res=x
    break
  x+=1
s.add(res)
print(min(s))

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 = 101
for i in range(101):
  if not i in P:
    if t > abs(i - x):
      t = abs(i - x)
      ans = i

print(ans)

Submission status: Wrong Answer

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