AtCoder Beginner Contest 170
C
Forbidden List
AtCoder
⌀ 15
原题
← BD →
翻译中…

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.

翻译中…

样例

Input #1
6 5
4 7 10 6 5
Output #1
8
Among the integers not contained in the sequence $4, 7, 10, 6, 5$, the one nearest to $6$ is $8$.
Input #2
10 5
4 7 10 6 5
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$.
Input #3
100 0
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.
题目信息
题号
abc170_c
时间限制
2 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。