#abc290c. C - Max MEX
C - Max MEX
Score : points
问题描述
你将得到一个长度为 的非负整数序列。
当 是通过从 中选择 个元素并按原顺序拼接而成的序列时,找出 可能的最大值。
这里,对于一个序列 ,我们定义 为满足以下条件的唯一非负整数 :
- 对于所有满足 的整数 ,都包含在 中。
- 不包含在 中。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
You are given a length- sequence of non-negative integers.
When is a sequence obtained by choosing elements from and concatenating them without changing the order, find the maximum possible value of .
Here, for a sequence , we define as the unique non-negative integer that satisfies the following conditions:
- Every integer such that is contained in .
- is not contained in .
Constraints
- All values in the input are integers.
Input
The input is given from Standard Input in the following format:
Output
Print the answer.
Sample Input 1
7 3
2 0 2 3 2 1 9
Sample Output 1
3
In this input, , and you obtain the sequence by picking elements. For example,
- If the -st, -nd, and -rd elements are chosen, .
- If the -rd, -th, and -th elements are chosen, .
- If the -nd, -th, and -th elements are chosen, .
- If the -nd, -rd, and -th elements are chosen, .
The maximum possible is .
update @ 2024/3/10 12:06:48