knapsack algorithm using greedy method in c