QOJ.ac

QOJ

时间限制: 1 s 内存限制: 1024 MB 总分: 100

#8889. 冰淇淋机

统计

作为一名地道的冰岛人,Arnar 非常热爱冰淇淋。今天天气极好,正是享用这份美味的最佳时机。他顶着暴风雪来到他最爱的冰淇淋店,却惊讶地发现排在前面的队伍异常短;他竟然是第 $n$ 位等待点餐的顾客!

Arnar 对这家冰淇淋店非常了解。店里提供 $m$ 种不同的口味,并且拥有 $k$ 台冰淇淋机。然而,每台机器一次只能供应一种口味,且在更换口味前必须先进行清洗。由于清洗机器需要时间,而 Arnar 又赶时间,他想知道是否能帮助店员在每次需要新口味来服务顾客时,确定最优的机器进行清洗,从而使机器总的清洗次数最少。

幸运的是,冰岛是个小地方,Arnar 认识排队中的每一个人,也知道他们想要的冰淇淋口味。店里严格执行不准插队的政策,因此他们将按照顾客到达的顺序进行服务。你能帮 Arnar 计算出为了服务队列中的所有人(包括他自己),冰淇淋机最少需要清洗多少次吗?

最初,所有的冰淇淋机都是空的,在装入第一种口味之前需要进行清洗。一旦某台冰淇淋机装入了某种特定口味,它就可以用来服务任何想要该口味的顾客,直到该机器被清洗并装入另一种口味为止。完全未被使用的机器不需要清洗。

输入格式

输入包含: 第一行包含三个整数 $n$、$m$ 和 $k$,分别表示排队等待的顾客人数、可提供的口味数量以及冰淇淋机的数量。 接下来 $n$ 行,第 $i$ 行包含一个整数 $c_i$($1 \le c_i \le m$),表示第 $i$ 位顾客想要的口味。

输出格式

输出为了服务所有 $n$ 位顾客,冰淇淋机所需的最少总清洗次数。

子任务

子任务 分值 数据范围
1 7 $N \le 1\,000, M \le 10, K = 1$
2 12 $N \le 1\,000, M \le 10, K \le 2$
3 22 $N \le 1\,000, M \le 10, K \le 5$
4 11 $N \le 1\,000, M \le 200, K \le 100$
5 14 $N \le 2 \cdot 10^5, M \le 500, K \le 100$
6 13 $N \le 2 \cdot 10^5, M \le 2 \cdot 10^5, K \le 100$
7 21 $N \le 2 \cdot 10^5, M \le 2 \cdot 10^5, K \le 2 \cdot 10^5$

样例

样例输入 1

8 3 1
2
3
3
1
2
1
1
3

样例输出 1

6

样例输入 2

8 3 2
2
3
3
1
2
1
1
3

样例输出 2

4

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.