QOJ.ac

QOJ

حد الوقت: 5 s - 8 s حد الذاكرة: 1024 MB مجموع النقاط: 13

#5945. 数据打包

الإحصائيات

Adam 是一个非常有条理的人,他一直对整理自己的物品很感兴趣。他特别怀念年轻时花大量时间将文件从电脑刻录到光盘上的时光。

在这个过程中有两条非常重要的规则。首先,为了确保所有光盘都能清晰地贴上标签,Adam 从不在同一张光盘上放置超过两个文件。其次,他从不将单个文件拆分到多张光盘上。幸运的是,他使用的光盘容量总是足够大,使得这些操作成为可能。

回想起来,Adam 现在想知道他当时是否以最好的方式整理了文件,或者是否浪费了一些光盘。他会提供所用光盘的容量(他所有的光盘容量相同)以及他存储的文件大小列表。请帮助 Adam 确定存储所有文件所需的最少光盘数量——当然,必须遵循那两条非常重要的规则。

输入格式

输入的第一行包含测试用例的数量 $T$。接下来是 $T$ 个测试用例。每个测试用例的第一行包含两个整数:需要存储的文件数量 $N$ 和所用光盘的容量 $X$(单位为 MB)。下一行包含 $N$ 个整数,表示文件的大小 $S_i$(单位为 MB),以空格分隔。

输出格式

对于每个测试用例,输出一行 "Case #x: y",其中 $x$ 是测试用例编号(从 1 开始),$y$ 是存储给定文件所需的最少光盘数量。

数据范围

$1 \le T \le 100$ $1 \le X \le 700$ $1 \le S_i \le X$

小数据(5 分)

$1 \le N \le 10$

大数据(8 分)

$1 \le N \le 10^4$

样例

样例输入 1

3
3 100
10 20 70
4 100
30 40 60 70
5 100
10 20 30 40 60

样例输出 1

Case #1: 2
Case #2: 2
Case #3: 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.