#P11012. 「ALFR Round 4」B 颜料
「ALFR Round 4」B 颜料
Background
In Xiaoshan's view, an art exhibition is brilliant because of different colors.
Problem Description
Xiaoshan has a total of paintings, and each painting has its main paint. Specifically, the main paint type of the -th painting is . Xiaoshan can choose a segment of paintings with consecutive indices to form an exhibition. The brilliance of the exhibition (suppose it consists of paintings from the -th to the -th) is , where is the number of times paint type appears in the exhibition, and is the value range of all paint types.
Now Xiaoshan wants to know: to make the exhibition's brilliance at least , what is the minimum number of consecutive paintings that must be selected? If there is no exhibition whose brilliance is at least , output .
Input Format
There are two lines.
The first line contains two integers , with meanings as described in the Description.
The second line contains integers. The -th integer is , representing the main paint type of the -th painting.
Output Format
Output one integer in a single line, which is the answer.
10 6
2 3 4 3 3 4 2 4 9 2
5
Hint
Sample Explanation
Choose paintings to to form an exhibition. Then $c_1=0,c_2=1,c_3=1,c_4=2,c_5=0,c_6=0,c_7=0,c_8=0,c_9=1$, and . It is easy to see that is the shortest length of a valid segment.
Constraints
| Subtask | Points | Constraints |
|---|---|---|
| All are the same | ||
| - |
For of the testdata, , .
Translated by ChatGPT 5