##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
##### ###### ##### ### # # ### # # ###### ## ## ## ## ## ## ## # # # # # ## ##### #### ##### # # # # # # # #### ## # ## ## ## ## # # # # # ## ## # ###### ## ### # ### # ######
3 3 100 200 50 0 30 80 1 50 100 2 60 150
50 60 50
1 1 500 1 25 100
375
2 2 10 20 0 50 5 2 15 15
0 0
You are given products with prices and discount coupons. Each coupon is described by three integers :
A coupon may only be applied to product when (the minimum-price requirement). You may apply at most one coupon per product.
For each product, determine the lowest possible price after optimally choosing a coupon (or choosing none at all).
Product 0 (price 100): coupon 0 gives , coupon 1 gives , coupon 2 requires so it is not applicable. Best: 50.
Product 1 (price 200): coupon 0 gives , coupon 1 gives , coupon 2 gives . Best: 60.
Product 2 (price 50): all coupons require , none applicable. Best: 50.
Product 0 (price 500): the only coupon gives . Best: 375.
Product 0 (price 10): coupon 0 gives , coupon 1 requires so not applicable. Best: 0.
Product 1 (price 20): coupon 0 gives , coupon 1 gives . Best: 0.