【发布时间】:2012-11-15 18:52:22
【问题描述】:
假设我们有一个输入:
10 // saying 1st property should be 10(in total)
10 // saying 2d property should be 10 (in total)
5 // saying theres 5 records below
// (1st property) (2nd property) (cost)
2 5 8
7 3 10
4 2 9
4 3 5
8 5 15
在这种情况下,输出将如下所示:
22 // lowest possible cost
1 3 4 // indexes of records, we've been using (indexing starts with 1)
2 5 8
4 2 9
4 3 5
+---------
10 10 22
如果无法将这些属性设为 10 和 10,程序将输出 -1; 我知道如何解决背包问题,但是我不知道如何解决这个问题。
【问题讨论】:
标签: algorithm knapsack-problem