23 using Objects = std::vector<std::pair<int, int>>;
24 Objects objects{ { 1, 3 }, { 2, 2 }, { 3, 65 }, { 1, 1 }, { 2, 2 },
25 { 4, 3 }, { 1, 1 }, { 10, 23 } };
26 const int capacity = 6;
27 auto size = [](std::pair<int, int> object) {
return object.first; }
29 auto value = [](std::pair<int, int> object) {
return object.second; }
32 std::cout <<
"Knapsack 0 / 1 no output" << std::endl;
36 std::cout <<
"Max value " << maxValue.first <<
", Total size "
37 << maxValue.second << std::endl;
int main()
[Knapsack Example]
auto knapsack_0_1_no_output(Objects &&objects, detail::FunctorOnRangePValue< ObjectSizeFunctor, Objects > capacity, ObjectSizeFunctor size, ObjectValueFunctor value=ObjectValueFunctor{})
Solution to Knapsack 0/1 problem, without retrieving the objects in the solution. ...