[USACO 2013 Jan]Cow Lineup
题目
Description
Cow Lineup [Brian Dean and Daniel Dara, 2012] Farmer John’s N cows
(1 <= N <= 100,000) are lined up in a row. Each cow is identified
by an integer “breed ID” in the range 0…1,000,000,000; the breed
ID of the ith cow in the lineup is B(i). Multiple cows can share the
same breed ID. FJ thinks that his line of cows will look much more
impressive if there is a large contiguous block of cows that all have
the same breed ID. In order to create such a block, FJ chooses up to K
breed IDs and removes from his lineup all the cows having those IDs.
Please help FJ figure out the length of the largest consecutive block
of cows with the same breed ID that he can create by doing this.
有N头牛(1 <= N <= 100,000) 排成一列。每头牛有一个标号,范围在0到1000000000,
第 i 头牛的编号为B(i)。多头牛可以共享一个编号。John想,如果前后相邻的多头牛
能有相同的编号,将会更好。为了使前后相连且编号相同的牛的数量尽可能多,
John将选择 K 个编号,然后移除编号与这K个编号相同的牛。请帮忙选择编号。
Input
第1行:N和K
第2至N+1行:Line i+1 第i头牛的编号 B(i)
Output
连续的编号相同的牛的最大总数。
Sample Input
9 1
2
7
3
7
7
3
7
5
7
有9头牛,要选择1个编号的牛移除。
Sample Output
4
提示:通过移除编号是