Elevator weight knapsack problem in c++