atcoder#ABC194E. [ABC194E] Mex Min
[ABC194E] Mex Min
Score : points
Problem Statement
Let us define as the smallest non-negative integer that does not occur in . You are given an integer sequence of length : . For each integer such that , we compute $\mathrm{mex}(A_{i + 1}, A_{i + 2}, A_{i + 3}, \dots, A_{i + M})$. Find the minimum among the results of these computations.
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the answer.
3 2
0 0 1
1
We have:
- for : $\mathrm{mex}(A_{i + 1}, A_{i + 2}) = \mathrm{mex}(0, 0) = 1$
- for : $\mathrm{mex}(A_{i + 1}, A_{i + 2}) = \mathrm{mex}(0, 1) = 2$
Thus, the answer is the minimum among and , which is .
3 2
1 1 1
0
We have:
- for : $\mathrm{mex}(A_{i + 1}, A_{i + 2}) = \mathrm{mex}(1, 1) = 0$
- for : $\mathrm{mex}(A_{i + 1}, A_{i + 2}) = \mathrm{mex}(1, 1) = 0$
3 2
0 1 0
2
We have:
- for : $\mathrm{mex}(A_{i + 1}, A_{i + 2}) = \mathrm{mex}(0, 1) = 2$
- for : $\mathrm{mex}(A_{i + 1}, A_{i + 2}) = \mathrm{mex}(1, 0) = 2$
7 3
0 0 1 2 0 1 0
2