Java算法
e.g. Say you had a voucher for $100 and the items in
the shop were worth: $87, $20, $99, $12, then the most you could spend would be the full
$100 (just buy 5 of the $20 item) so there would be zero waste, whereas, if the items in
the shop were worth: $87, $22, $30, $45 then the most you could spend would be $97
意思大概是
代金券不找零,怎样才能最大化使用代金券。例如: 你有一张100元的代金券,商店里的物品价值:87元,20元,99元,12元,则最优方法是:(买5个价值20元的物品)。
如果商店里的物品价值:87元,22元,30元,45元,则最优方法是:(买22+30+45 = 97)。
请问各路大神有什么想法