F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Sequence

Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 325    Accepted Submission(s): 69


Problem Description
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.
 

Input
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$.
 

Output
For each test case, print one integer in one line, denoting the maximal sum of the uniqueness.
 

Sample Input
2 2 1 1 3 2 1 1 1 4 2 1 2 2 1 6 3 1 1 2 2 3 3
 

Sample Output
2 1 4 4
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-05-11 19:58:42, Gzip enabled