
ZOJ Problem Set  3790
There are N (1 ≤ N ≤ 10^{5}) colored blocks (numbered 1 to N from left to right) which are lined up in a row. And the ith block's color is C_{i} (1 ≤ C_{i} ≤ 10^{9}). Now you can remove at most K (0 ≤ K ≤ N) blocks, then rearrange the blocks by their index from left to right. Please figure out the length of the largest consecutive blocks with the same color in the new blocks created by doing this. For example, one sequence is {1 1 1 2 2 3 2 2} and K=1. We can remove the 6th block, then we will get sequence {1 1 1 2 2 2 2}. The length of the largest consecutive blocks with the same color is 4. InputInput will consist of multiple test cases and each case will consist of two lines. For each test case the program has to read the integers N and K, separated by a blank, from the first line. The color of the blocks will be given in the second line of the test case, separated by a blank. The ith integer means C_{i}. OutputPlease output the corresponding length of the largest consecutive blocks, one line for one case. Sample Input8 1 1 1 1 2 2 3 2 2 Sample Output4 Author: LIN, Xi Source: ZOJ Monthly, June 2014 