Double Rainbow

์•„์ง ์ œ์ถœ์ด ์—†์Šต๋‹ˆ๋‹ค์‹œ๊ฐ„ ์ œํ•œ1์ดˆ๋ฉ”๋ชจ๋ฆฌ ์ œํ•œ1024 MB

๋ฌธ์ œ

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 Pโ€ฒP' of consecutive points from PP, if both Pโ€ฒP' and P\Pโ€ฒP \backslash P' contain at least one point of each color, then we say that Pโ€ฒP' 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 Pโ€ฒP' 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 Pโ€ฒP' 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,0001 โ‰ค 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 Pโ€ฒP' that makes a double rainbow. If there is no such Pโ€ฒP', print 0.