cswork / OA打开练习工作台

SnowflakeOA #12

Unequal Elements (Also for Core/Database Intern :)

估计中等可在线判题

考点(AI 标注)子序列哈希计数

Choose a subsequence of the skill array in which the number of adjacent elements with different values is at most k, and find its maximum length. The subsequence does not need to be contiguous.

输入格式

The first line contains n k, and the second line contains n skill values. The original text gives n≤2000 and the remaining constraints are truncated; this site specifies 1≤n≤2000, 0≤k<n, and 1≤skill value≤10⁹.

输出格式

Output the single integer required by the problem.

样例 1

输入:

6 2
1 1 2 3 2 1

输出:

5

样例 2

输入:

5 0
1 2 1 2 1

输出:

3

样例 3

输入:

1 0
1

输出:

1

样例说明

The answers to the three public examples are, in order: 5; 3; 1. All examples have been verified by independent small-scale enumeration or state search.