dynamic programming: vending machine