Knapsack K-Best implementation