QOJ.ac

QOJ

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

#11908. 装箱问题

Statistics

给定 $n$ 个重量分别为 $w_1, w_2, \dots, w_n$ 的物品。你需要将所有 $n$ 个物品装入最少数量的箱子中,且每个箱子内物品的总重量不得超过 $S$。

输入格式

第一行包含两个整数 $n$ 和 $S$,其中 $1 \le n \le 24$ 且 $1 \le S \le 10^8$。第二行包含 $w_1, w_2, \dots, w_n$,其中 $1 \le w_i \le S$。

输出格式

输出装下所有给定物品所需的最少箱子数量。

样例

样例输入 1

4 10
5 6 3 7

样例输出 1

3

说明

这些物品可以装入三个容量为 10 的箱子中,分配方式如下:$[5, 3], [6], [7]$。由于物品总重量为 21,因此无法将它们装入两个箱子中。

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.