n fruits. Fruit i costs prices[i] coins and is worth flavor[i] flavor points. You have budget coins and coupons coupons.
Each fruit can be bought at most once. A coupon can be applied to a purchase, making that fruit cost half its price rounded down (prices[i] // 2). You may use at most coupons coupons in total and at most one per fruit.
The total amount you pay must not exceed budget. Return the largest total flavor you can collect.prices=[8, 6, 12], flavor=[4, 7, 9], budget=12, coupons=1 → 16
Buy the 12-coin fruit with the coupon (6) and the 6-coin fruit at full price: exactly 12 coins and 9 + 7 = 16 flavor.
prices=[0, 9], flavor=[5, 6], budget=4, coupons=2 → 11
The first fruit is free, and the second costs 9 // 2 = 4 with a coupon. That is 4 coins and 11 flavor.
prices=[7, 5], flavor=[3, 8], budget=3, coupons=0 → 0
prices=[8, 6, 12], flavor=[4, 7, 9], budget=12, coupons=1
16
Run checks the first 3 tests in your browser. Submit checks all 111 tests on the server, hidden ones included.