题目来源:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=3&page=show_problem&problem=38  Ecological Bin Packing  Background Bin packing, or the placement of objects of certain weights into different bins subject…
Background Bin packing, or the placement of objects of certain weights into different bins subject to certain constraints, is an historically interesting problem. Some bin packing problems are NP-complete but are amenable to dynamic programming solut…
首先对物品按重量从小到大排序排序. 因为每个背包最多装两个物品,所以直觉上是最轻的和最重的放一起最节省空间. 考虑最轻的物品i和最重的物品j,如果ij可以放在一个包里那就放在一起. 否则的话,j只能自己单独放在一个包里,因为最轻的都不行,其他物品就更不可能和j放在一起了. 如果j可以和多个物品放在一起,那么j和最轻的i放一起,剩下的一定能和除j外最重的放一起. #include <cstdio> #include <algorithm> using namespace std; +…
[链接] 我是链接,点我呀:) [题意] 在这里输入题意 [题解] 每个背包只能装两个东西. 而且每个东西都要被装进去. 那么我们随意考虑某个物品.(不必要求顺序 这个物品肯定要放进某个背包里面的. 那么背包数递增. 那么剩余的空间. 只能装一个了. 要装谁呢? 肯定是尽可能装较大的.所以用upper_bound-1找一个最大的能装的装就可以了. 这样就能尽量减少体积较大的物品了. [代码] /* 1.Shoud it use long long ? 2.Have you ever test s…
Bin Packing 题目链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=85904#problem/F 题目: A set of n<tex2html_verbatim_mark> 1-dimensional items have to be packed in identical bins. All bins have exactly the same length l<tex2html_verbatim_mark&…
Vector bin packing:first fit / best fit / grasp 成本:性价比 (先验) 设计评价函数: evaluation function:cosine similarity / vertical distance / dynamic programming 搜索: 启发式方法
local search 邻域解 population based 粒子群优化,遗传算法,模拟退火 simulated annealing 模拟退火 应用 Solution 邻域拆分/…
传送门 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 pa…
A set of n 1-dimensional items have to be packed in identical bins. All bins have exactly the samelength 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…
题意:给定n个物品的重量l[i],背包的容量为w,同时要求每个背包最多装两个物品,求至少要多少个背包才能装下所有的物品 和之前做的独木舟上的旅行一样,注意一下格式就好了 #include<iostream> #include<cstdio> #include<cstring> #include <cmath> #include<stack> #include<vector> #include<map> #include&l…
题意:给定N物品的重量,背包容量M,一个背包最多放两个东西.问至少多少个背包. 思路:贪心,最大的和最小的放.如果这样都不行,那最大的一定孤独终生.否则,相伴而行. 代码: #include <cstdio> #include <cstring> #include <algorithm> using namespace std; #define N 100100 int a[N]; int main() { int t; scanf("%d", &a…