Problem p02641 (python)

Fixed submission:
x, n = map(int, input().split())
p = list(map(int, input().split()))
if n == 0:
  print(x)
  exit()
  
# x, n = 10, 5
# p =  [4, 7, 10, 6, 5]
# ->9が解
# x, n = 6, 5
# p = [4, 7, 10, 6, 5]

# x, n = 1, 1
# # p = list(range(1, 101))
# p = [1]

# pに含まれない整数リストを、最小値-1最大値+1も含めて求める
pl = min(p)-1
pr = max(p)+2
npl = list(range(pl, pr))
np = list(set(npl) - set(p))
if len(np) == 0:
  print(x)
  exit()
np.sort()

# np内で最もxに近い数値を算出する
mx = x
res = np[0]
for k in np:
  t = abs(k - x)
  if t < mx:
    mx = t
    res = k
 
print(res)

Buggy submission (verdict: Runtime Error):
x, n = map(int, input().split())
if n == 0:
  input()
  print(x)
else:
  p = list(map(int, input().split()))

# x, n = 10, 5
# p =  [4, 7, 10, 6, 5]
# ->9が解
# x, n = 6, 5
# p = [4, 7, 10, 6, 5]

# x, n = 1, 1
# # p = list(range(1, 101))
# p = [1]

# pに含まれない整数リストを、最小値-1最大値+1も含めて求める
pl = min(p)-1
pr = max(p)+2
npl = list(range(pl, pr))
np = list(set(npl) - set(p))
np.sort()

# np内で最もxに近い数値を算出する
mx = x
res = np[0]
for k in np:
  t = abs(k - x)
  if t < mx:
    mx = t
    res = k
 
print(res)

Buggy submission (verdict: Runtime Error):
x, n = map(int, input().split())
if n == 0:
  print(x)
else:
  p = list(map(int, input().split()))

# x, n = 10, 5
# p =  [4, 7, 10, 6, 5]
# ->9が解
# x, n = 6, 5
# p = [4, 7, 10, 6, 5]

# x, n = 1, 1
# # p = list(range(1, 101))
# p = [1]

# pに含まれない整数リストを、最小値-1最大値+1も含めて求める
pl = min(p)-1
pr = max(p)+2
npl = list(range(pl, pr))
np = list(set(npl) - set(p))
np.sort()

# np内で最もxに近い数値を算出する
mx = x
res = np[0]
for k in np:
  t = abs(k - x)
  if t < mx:
    mx = t
    res = k
 
print(res)

Buggy submission (verdict: Runtime Error):
x, n = map(int, input().split())
p = list(map(int, input().split()))
if n == 0:
  print(x)

# x, n = 10, 5
# p =  [4, 7, 10, 6, 5]
# ->9が解
# x, n = 6, 5
# p = [4, 7, 10, 6, 5]

# x, n = 1, 1
# # p = list(range(1, 101))
# p = [1]

# pに含まれない整数リストを、最小値-1最大値+1も含めて求める
pl = min(p)-1
pr = max(p)+2
npl = list(range(pl, pr))
np = list(set(npl) - set(p))
np.sort()

# np内で最もxに近い数値を算出する
mx = x
res = np[0]
for k in np:
  t = abs(k - x)
  if t < mx:
    mx = t
    res = k
 
print(res)

Buggy submission (verdict: Runtime Error):
x, n = map(int, input().split())
p = list(map(int, input().split()))
if n == 0:
  print(x)

# x, n = 10, 5
# p =  [4, 7, 10, 6, 5]
# ->9が解
# x, n = 6, 5
# p = [4, 7, 10, 6, 5]

# pに含まれない整数リストを、最小値-1最大値+1も含めて求める
pl = min(p)-1
pr = max(p)+2
npl = list(range(pl, pr))
np = list(set(npl) - set(p))
np.sort()

# np内で最もxに近い数値を算出する
mx = x
res = x
for k in np:
  t = abs(k - x)
  if t < mx:
    mx = t
    res = k
 
print(res)

Buggy submission (verdict: Runtime Error):
x, n = map(int, input().split())
if n != 0:
  p = list(map(int, input().split()))
else:
  input()
  print(x)

# x, n = 10, 5
# p =  [4, 7, 10, 6, 5]
# ->9が解
# x, n = 6, 5
# p = [4, 7, 10, 6, 5]

# pに含まれない整数リストを、最小値-1最大値+1も含めて求める
pl = min(p)-1
pr = max(p)+2
npl = list(range(pl, pr))
np = list(set(npl) - set(p))
np.sort()

# np内で最もxに近い数値を算出する
mx = x
res = x
for k in np:
  t = abs(k - x)
  if t < mx:
    mx = t
    res = k
 
print(res)

Buggy submission (verdict: Runtime Error):
x, n = map(int, input().split())
if n != 0:
  p = list(map(int, input().split()))
else:
  print(x)

# x, n = 10, 5
# p =  [4, 7, 10, 6, 5]
# ->9が解
# x, n = 6, 5
# p = [4, 7, 10, 6, 5]

# pに含まれない整数リストを、最小値-1最大値+1も含めて求める
pl = min(p)-1
pr = max(p)+2
npl = list(range(pl, pr))
np = list(set(npl) - set(p))
np.sort()

# np内で最もxに近い数値を算出する
mx = x
res = x
for k in np:
  t = abs(k - x)
  if t < mx:
    mx = t
    res = k
 
print(res)

Buggy submission (verdict: Runtime Error):
x, n = map(int, input().split())
if n != 0:
  p = list(map(int, input().split()))
else:
  print(x)

# x, n = 10, 5
# p =  [4, 7, 10, 6, 5]
# ->9が解

# pに含まれない整数リストを、最小値-1最大値+1も含めて求める
pl = min(p)-1
pr = max(p)+1
npl = list(range(pl, pr))
np = list(set(npl) - set(p))
np.sort()

# np内で最もxに近い数値を算出する
mx = x
res = x
for k in np:
  t = abs(k - x)
  if t < mx:
    mx = t
    res = k

print(k)

Buggy submission (verdict: Runtime Error):
x, n = map(int, input().split())
if n != 0:
  p = list(map(int, input().split()))

# x, n = 10, 5
# p =  [4, 7, 10, 6, 5]
# ->9が解

# pに含まれない整数リストを、最小値-1最大値+1も含めて求める
pl = min(p)-1
pr = max(p)+1
npl = list(range(pl, pr))
np = list(set(npl) - set(p))
np.sort()

# np内で最もxに近い数値を算出する
mx = x
res = x
for k in np:
  t = abs(k - x)
  if t < mx:
    mx = t
    res = k

print(k)

Buggy submission (verdict: Runtime Error):
x, n = map(int, input().split())
p = list(map(int, input().split()))


# x, n = 10, 5
# p =  [4, 7, 10, 6, 5]
# ->9が解

# pに含まれない整数リストを、最小値-1最大値+1も含めて求める
p.sort()
pl = min(p)-1
pr = max(p)+1
npl = list(range(pl, pr))
np = list(set(npl) - set(p))
np.sort()

# np内で最もxに近い数値を算出する
mx = x
res = x
for k in np:
  t = abs(k - x)
  if t < mx:
    mx = t
    res = k

print(k)