PivotOJ

Double Rainbow

시간 제한: 1000ms메모리 제한: 1024MB출처: ICPC Asia Seoul Regional 2021BOJ 23567

문제

Let PP be a set of nn points on the xx-axis and each of the points is colored with one of the colors 1,2,,k1, 2, \dots , k. For each color 𝑖 of the 𝑘 colors, there is at least one point in PP which is colored with ii. For a set PP' of consecutive points from PP, if both PP' and P\PP \backslash P' contain at least one point of each color, then we say that PP' 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 11, 22, 33, and 44. The set PP' of the five consecutive points contained in the rectangle makes a double rainbow.

Given a set PP of points and the number kk of colors as input, write a program that computes and prints out the minimum size of PP' that makes a double rainbow.

입력

Your program is to read from standard input. The input starts with a line containing two integers nn and kk (1 ≤ k ≤ n ≤ 10,000), where nn is the number of the points in PP and kk is the number of the colors. Each of the following nn lines consists of an integer from 11 to kk, inclusively, and the ii-th line corresponds to the color of the ii-th point of PP from the left.

출력

Your program is to write to standard output. Print exactly one line. The line should contain the minimum size of PP' that makes a double rainbow. If there is no such PP', print 0.

예제

예제 1

입력
10 4
1
2
3
1
1
4
2
4
3
3
출력
5

예제 2

입력
6 3
1
1
2
2
3
3
출력
0
코드를 제출하려면 로그인하세요.