cswork / OAOpen practice workspace

AmazonOA #278

Maximum Possible Racers

Estimated MediumJudge-ready

Topics (AI-labelled)Two PointersHashing

Remove at most k racers; everyone else keeps their original relative order. Find the maximum number of people in a contiguous same-speed segment of the remaining line. Output the number of people who stay in that segment, not counting removed racers.

Input

The first line contains n k and the second line contains speed. On this site 1≤n≤200000, 0≤k≤n, 1≤speed[i]≤10^9. The original index typo "0 to n" is unified as 0..n−1 for n items.

Output

Output a single integer, the answer.

Example 1

Input:

5 1
1 2 1 2 1

Output:

2

Example 2

Input:

4 0
3 3 4 3

Output:

2

Example 3

Input:

3 3
1 2 3

Output:

1

Example notes

The answers are 2, 2 and 1 respectively. In the first example, removing only one 2 is still not enough to connect the three 1s.

Editorial

Loading solution…