300961: CF180E. Cubes

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Cubes

题意翻译

### 题意简述 现有一数列 $a_1,a_2,\dots,a_n(1\le a_i \le m)$,求在最多删去 $k$ 个位置的数后,所能获得的最长连续子段的长度(该子段中所有数均相同). ### 解释 - 可以不删数. - $1 \le n \le 2 \times 10^5$,$1 \le m \le 10^5$,$0 \le k <n$. - 样例#1:删去 $5th$ 和 $6th$. - 样例#2:删去 $4th$ 和 $7th$. - 样例#3:不变. - Translated by SHIROKU ([@SerokSSR](https://www.luogu.com.cn/user/125032))

题目描述

Let's imagine that you're playing the following simple computer game. The screen displays $ n $ lined-up cubes. Each cube is painted one of $ m $ colors. You are allowed to delete not more than $ k $ cubes (that do not necessarily go one after another). After that, the remaining cubes join together (so that the gaps are closed) and the system counts the score. The number of points you score equals to the length of the maximum sequence of cubes of the same color that follow consecutively. Write a program that determines the maximum possible number of points you can score. Remember, you may delete no more than $ k $ any cubes. It is allowed not to delete cubes at all.

输入输出格式

输入格式


The first line contains three integers $ n $ , $ m $ and $ k $ ( $ 1<=n<=2·10^{5},1<=m<=10^{5},0<=k&lt;n $ ). The second line contains $ n $ integers from $ 1 $ to $ m $ — the numbers of cube colors. The numbers of colors are separated by single spaces.

输出格式


Print the maximum possible number of points you can score.

输入输出样例

输入样例 #1

10 3 2
1 2 1 1 3 2 1 1 2 2

输出样例 #1

4

输入样例 #2

10 2 2
1 2 1 2 1 1 2 1 1 2

输出样例 #2

5

输入样例 #3

3 1 2
1 1 1

输出样例 #3

3

说明

In the first sample you should delete the fifth and the sixth cubes. In the second sample you should delete the fourth and the seventh cubes. In the third sample you shouldn't delete any cubes.

Input

题意翻译

### 题意简述 现有一数列 $a_1,a_2,\dots,a_n(1\le a_i \le m)$,求在最多删去 $k$ 个位置的数后,所能获得的最长连续子段的长度(该子段中所有数均相同). ### 解释 - 可以不删数. - $1 \le n \le 2 \times 10^5$,$1 \le m \le 10^5$,$0 \le k <n$. - 样例#1:删去 $5th$ 和 $6th$. - 样例#2:删去 $4th$ 和 $7th$. - 样例#3:不变. - Translated by SHIROKU ([@SerokSSR](https://www.luogu.com.cn/user/125032))

加入题单

上一题 下一题 算法标签: