Cow Lineup
의견: 0
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.
Line 1: Two space-separated integers: N and K.
Lines 2..1+N: Line i+1 contains the breed ID B(i).
The largest size of a contiguous block of cows with identical breed IDs that FJ can create.
lineup.inlineup.out9 1
2
7
3
7
7
3
7
5
74Input details: There are 9 cows with breed IDs 2, 7, 3, 7, 7, 3, 7, 5, 7. FJ may remove up to 1 breed ID.
Output details: By removing all cows with breed ID 3, there is a contiguous block of 4 cows with breed ID 7.
평가 및 의견
Cow Lineup
아직 의견이 없습니다. 자격이 된다면 위 양식에서 가장 먼저 평가해 보세요.
풀이 제출
Cow Lineup