#P14735. [ICPC 2021 Seoul R] Double Rainbow
[ICPC 2021 Seoul R] Double Rainbow
题目描述
Let be a set of points on the x-axis and each of the points is colored with one of the colors . For each color of the colors, there is at least one point in which is colored with . For a set of consecutive points from , if both and contain at least one point of each color, then we say that makes a double rainbow. See the below figure as an example. The set consists of ten points and each of the points is colored by one of the colors , and . The set of the five consecutive points contained in the rectangle makes a double rainbow.
:::align{center}
:::
Given a set of points and the number of colors as input, write a program that computes and prints out the minimum size of that makes a double rainbow.
输入格式
Your program is to read from standard input. The input starts with a line containing two integers and (), where is the number of the points in and is the number of the colors. Each of the following lines consists of an integer from to , inclusively, and the -th line corresponds to the color of the -th point of from the left.
输出格式
Your program is to write to standard output. Print exactly one line. The line should contain the minimum size of that makes a double rainbow. If there is no such , print .
10 4
1
2
3
1
1
4
2
4
3
3
5
6 3
1
1
2
2
3
3
0