当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

6602:Longest Subarray

题目描述
You are given two integers $C, K$ and an array of $N$ integers $a_1, a_2, ..., a_N$. It is guaranteed that the value of $a_i$ is between $1$ to $C$.

We define that a continuous subsequence $a_l, a_{l + 1}, ..., a_r(l\leq r)$ of array a is a good subarray if and only if the following condition is met:

\begin{equation*}
\forall x \in [1, C], \; \sum\limits_{i = l}^r[a_i = x] = 0 \; or \; \sum\limits_{i = l}^r[a_i = x] \geq K
\end{equation*}

It implies that if a number appears in the subarray, it will appear no less than $K$ times.

You should find the longest good subarray and output its length. Or you should print $0$ if you cannot find any.
输入解释
There are multiple test cases.

Each case starts with a line containing three positive integers $N,C,K(N,C,K \leq 10^5)$.

The second line contains $N$ integer $a_1, a_2, ..., a_N(1 \leq a_i \leq C)$.

We guarantee that the sum of $N$s, the sum of $C$s and the sum of $K$s in all test cases are all no larger than $5 \times 10^5$.
输出解释
For each test case, output one line containing an integer denoting the length of the longest good subarray.
输入样例
7 4 2
2 1 4 1 4 3 2
输出样例
4
来自杭电HDUOJ的附加信息
Recommend liuyiding

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-6602

最后修改于 2020-10-25T23:32:43+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
2000/1000MS(Java/Others) 131072/131072K(Java/Others)