题目描述
Problem Description
Rasuk has a sequence of length $N$, denoted as $a$.
The boringness of a sequence is defined as the maximum length of a contiguous subsequence where all elements are the same.
Rasuk wants to change up to $K$ elements of the sequence $a$ to any integer in order to minimize the boringness.
Find the minimum boringness that can be achieved.
Input Format
The input is given from the standard input in the following format:
$ N $ $ K $ $ a_1 $ $ a_2 $ $\ldots$ $ a_N $
Output Format
Output the minimum boringness when up to $K$ elements of the sequence $a$ are changed.
Sample Input and Output
Sample Input #1
10 2
3 3 3 3 4 4 4 4 4 4
Sample Output #1
3
Sample Input #2
9 2
3 3 4 4 4 4 4 4 4
Sample Output #2
2
Sample Input #3
5 5
3 1 4 1 5
Sample Output #3
1
Notes/Hints
Constraints
- All input values are integers.
- $1 \leq K \leq N \leq 2 \times 10^5$
- $1 \leq a_i \leq N$
Sample Explanation 1
Changing the 1st element to $1$ and the 7th element to $2$, the sequence becomes $1, 3, 3, 3, 4, 4, 2, 4, 4, 4$, and the boringness is $3$.
Sample Explanation 2
Changing the 4th element to $5$ and the 7th element to $1$, the sequence becomes $3, 3, 4, 5, 4, 4, 1, 4, 4$, and the boringness is $2$.
Sample Explanation 3
No changes are necessary.
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分