UT Invitational Programming Contest Spring 2020

Start

2020-05-02 09:00 AKDT

UT Invitational Programming Contest Spring 2020

End

2020-05-02 14:00 AKDT
The end is near!
Contest is over.
Not yet started.
Contest is starting in -181 days 12:03:49

Time elapsed

5:00:00

Time remaining

0:00:00

Problem A
Colored Squares

Graphic design is Aditya’s new passion. He has launched his new company, Turmeric, and his first client comes to him to design a new logo. The old logo consists of $n$ colored squares in a row. The $i$-th square is painted in a color represented by a number $s_ i$ such that $1 \leq s_ i \leq c$, where $c$ is the total number of colors in the logo. Now, the client is a very picky person. He will not allow Aditya to change any of the square’s colors but he will give Aditya the artistic freedom to delete up to $k$ squares in the logo. Aditya thinks that the aesthetic score of a logo is equal to the maximum number of consecutive squares with the same color. Help Aditya figure out how to remove at most $k$ squares such that the aesthetic score of the new logo is maximized. Aditya may choose to not remove any squares.

Input

The first line of input is $3$ integers separated by spaces $n$, $c$, and $k$ such that $1 \leq n \leq 2 \cdot 10^5$ , $1 \leq c \leq 10^5$, and $1 \leq k < n$

The next line is $n$ integers $s_1, s_2 \ldots s_ n$ separated by spaces representing the color of each square in the pattern, such that $1 \leq s_ i \leq c$.

Output

Output a single integer, the maximum possible aesthetic score of the new logo.

Sample Input 1 Sample Output 1
3 1 2
1 1 1
3
Sample Input 2 Sample Output 2
10 3 2
1 2 1 1 3 2 1 1 2 2
4