cswork / OA打开练习工作台

AmazonOA #206

Get Max Racers

估计中等可在线判题

考点(AI 标注)双指针滑窗哈希计数

Remove at most k racers; the remaining racers keep their relative order. Find the number of racers in the longest contiguous run of the same speed in the remaining sequence. Removed racers do not count toward the answer.

输入格式

The first line contains n k; the second line contains the speeds. 1≤n≤300000, 1≤k≤n. The original text had no numeric bounds on speed; this site uses speeds 1..10^9.

输出格式

Output a single integer, the answer.

样例 1

输入:

6 2
1 4 4 2 2 4

输出:

3

样例 2

输入:

3 3
1 2 3

输出:

1

样例 3

输入:

3 1
5 5 5

输出:

3

样例说明

The answers are 3, 1 and 3.