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

建议使用的浏览器:

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

6946:Sequence

题目描述
We define the uniqueness of a sequence as the number of unique numbers in the sequence. For example, the uniqueness of $\{1,2,1,2\}$ is $0$ because there is no unique number, and the uniqueness of $\{5,6,7,6,6\}$ is $2$ because $5$ and $7$ are unique numbers.

You are given a sequence with length $N$. You need to cut it into $M$ parts (each part is a continuous subsequence), and maximize the sum of the uniqueness of the $M$ parts.
输入解释
There are multiple test cases.

For each test case, the first line contains $2$ integers $N$ and $M$.

The second line contains $N$ integers $A_1,A_2,\ldots,A_N$, denoting the sequence.

$1\leq M,A_i \leq N, ~ 2\leq M \leq 10$. The sum of $N$ of all the test cases is no more than $2 \cdot 10^5$.
输出解释
For each test case, print one integer in one line, denoting the maximal sum of the uniqueness.
输入样例
2 2
1 1
3 2
1 1 1
4 2
1 2 2 1
6 3
1 1 2 2 3 3
输出样例
2
1
4
4

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

源链接: HDU-6946

最后修改于 2021-10-23T19:10:46+00:00 由爬虫自动更新

共提交 0

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