AtCoder Beginner Contest 210
C
Colorful Candies
AtCoder
⌀ 357
原题
← BD →
翻译中…

Problem Statement

翻译中…

There are $N$ candies arranged in a row from left to right. Each of these candies has one color that is one of the $10^9$ colors called Color $1$, Color $2$, $\ldots$, and Color $10^9$. For each $i = 1, 2, \ldots, N$, the color of the $i$-th candy from the left is Color $c_i$.

翻译中…

From this row, Takahashi can choose $K$ consecutive candies and get them. That is, he can choose an integer $i$ such that $1 \leq i \leq N-K+1$ and get the $i$-th, $(i+1)$-th, $(i+2)$-th, $\ldots$, $(i+K-1)$-th candy from the left.

翻译中…

Takahashi likes to eat colorful candies, so the more variety of colors his candies have, the happier he will be. Print the maximum possible number of distinct colors in candies he gets.

翻译中…

Constraints

翻译中…
  • $1 \leq K \leq N \leq 3 \times 10^5$
  • $1 \leq c_i \leq 10^9$
  • All values in input are integers.
翻译中…

Input

翻译中…

Input is given from Standard Input in the following format:

翻译中…

N K
c_1 c_2 \ldots c_N

翻译中…

Output

翻译中…

Print the maximum possible number of distinct colors in candies Takahashi gets.

翻译中…

样例

Input #1
7 3
1 2 1 2 3 3 1
Output #1
3
If Takahashi gets the $3$-rd through $5$-th candies, they will have $3$ distinct colors, which is the maximum possible number.
Input #2
5 5
4 4 4 4 4
Output #2
1
Takahashi can get all of these candies, but they are in a single color.
Input #3
10 6
304621362 506696497 304621362 506696497 834022578 304621362 414720753 304621362 304621362 414720753
Output #3
4
题目信息
题号
abc210_c
时间限制
2 s
内存限制
1024 MB

题面与样例版权归 AtCoder 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。