当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

2782:Bin Packing

题目描述
A set of n 1-dimensional items have to be packed in identical bins. All bins have exactly the same length l and each item i has length li<=l . We look for a minimal number of bins q such that
  • each bin contains at most 2 items,
  • each item is packed in one of the q bins,
  • the sum of the lengths of the items packed in a bin does not exceed l .

You are requested, given the integer values n , l , l1 , ..., ln , to compute the optimal number of bins q .
输入解释
The first line of the input contains the number of items n (1<=n<=105) . The second line contains one integer that corresponds to the bin length l<=10000 . We then have n lines containing one integer value that represents the length of the items.
输出解释
Your program has to write the minimal number of bins required to pack all items.
输入样例
10
80
70
15
30
35
10
80
20
35
10
30
输出样例
6
提示
The sample instance and an optimal solution is shown in the figure below. Items are numbered from 1 to 10 according to the input order.

该题目是Virtual Judge题目,来自 北京大学POJ

源链接: POJ-2782

最后修改于 2020-10-29T06:43:26+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
2000 65536