QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 256 MB Total points: 100

#3408. 帮助 Bubu

Statistics

Bubu 的书架乱成一团了!帮帮他吧!

书架上有 $n$ 本书。我们将“混乱度”定义为连续且高度相等的书构成的段数。例如,如果书的高度依次为 30, 30, 31, 31, 32,则混乱度为 3;30, 32, 32, 31 的混乱度也是 3;而 31, 32, 31, 32, 31 的混乱度则是 5——这确实很乱!

Bubu 想尽可能降低混乱度,但他有点累了,所以他决定取出最多 $k$ 本书,然后将它们放回书架上的任意位置。你能帮帮他吗?

输入格式

输入包含最多 20 组测试数据。每组数据的第一行包含两个正整数 $n$ 和 $k$ ($1 \le k \le n \le 100$),分别表示书的总数和最多可以取出的书的数量。下一行包含 $n$ 个整数,表示从左到右每本书的高度。每本书的高度均为 25 到 32 之间的整数(包含 25 和 32)。输入以 $n=k=0$ 结束,该行无需处理。

输出格式

对于每组测试数据,输出测试用例编号和最小的最终混乱度。在每组测试数据的输出后打印一个空行。

样例

输入 1

5 2 
25 25 32 32 25 
5 1 
25 26 25 26 25 
0 0

输出 1

Case 1: 2 

Case 2: 3

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.