How do I sort the possibilities vector in 0/1 knapsack problem using the template min_max function I have written?
问题 SO already has multiple questions related to this topic. My question ain't 'bout the algorithm. It's 'bout sorting the final possibilities vector as per profit I wrote the following piece of code to solve the 0/1 knapsack problem: #include "algorithms.h" struct Item { int index = 1; int profit = 1; int weight = 1; Item() = delete; explicit Item(int i, int _profit, int w) { index = i; profit = _profit; weight = w; } bool operator<(const Item& item) { return this->profit < item.profit; } bool