logo AlgoBeat OnlineJudge
登录 注册

#214841. [ICPC 2021 Seoul R] Double Rainbow

内存限制:1024 MiB 时间限制:1000 ms 标准输入输出
题目类型:VJudge(洛谷) 评测方式:VJudge
上传者: 匿名

题目描述

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 .

样例

样例输入 1

10 4
1
2
3
1
1
4
2
4
3
3

样例输出 1

5

样例输入 2

6 3
1
1
2
2
3
3

样例输出 2

0