102451: [AtCoder]ABC245 B - Mex

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:6 Solved:0

Description

Score : $200$ points

Problem Statement

You are given a sequence of length $N$ consisting of integers: $A=(A_1,\ldots,A_N)$.

Find the smallest non-negative integer not in $(A_1,\ldots,A_N)$.

Constraints

  • $1 \leq N \leq 2000$
  • $0 \leq A_i \leq 2000$
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

$N$
$A_1$ $\ldots$ $A_N$

Output

Print the answer.


Sample Input 1

8
0 3 2 6 2 1 0 0

Sample Output 1

4

The non-negative integers are $0,1,2,3,4,\ldots$.
We have $0,1,2,3$ in $A$, but not $4$, so the answer is $4$.


Sample Input 2

3
2000 2000 2000

Sample Output 2

0

Input

题意翻译

给出 $n$ 个非负整数,请求出这 $n$ 个整数中不包含的最小的非负整数。

Output

分数:200分

问题描述

给你一个长度为 N 的整数序列 A:(A_1,\ldots,A_N)。

找出序列中不存在的最小的非负整数。

约束

  • $1 \leq N \leq 2000$
  • $0 \leq A_i \leq 2000$
  • 输入中的所有值都是整数。

输入

输入从标准输入按以下格式给出:

$N$
$A_1$ $\ldots$ $A_N$

输出

输出答案。


样例输入 1

8
0 3 2 6 2 1 0 0

样例输出 1

4

非负整数有 $0,1,2,3,4,\ldots$。
我们在 A 中有 $0,1,2,3$,但没有 $4$,所以答案是 $4$。


样例输入 2

3
2000 2000 2000

样例输出 2

0

加入题单

算法标签: