Backpack algoritm