Promo code cart discount

Write codeMedium28 min

Your task

A checkout engine applies promo codes to one cart. prices_cents[i] is what item i costs. Promo j arrives in two parallel lists: min_cents[j] is the lowest price an item may carry for that promo to apply to it, and off_cents[j] is what the promo takes off. A promo attaches to at most one item, an item accepts at most one promo, and off_cents[j] never exceeds min_cents[j]. Return the largest total number of cents the engine can take off this cart. The two promo lists have the same length as each other, prices are positive, and any list may be empty. Handing the biggest promo to the most expensive item it fits is not always the best move.

Examples

max_promo_savings(prices_cents: list[int], min_cents: list[int], off_cents: list[int]) -> int
Example 1
Inputmax_promo_savings([10000, 50000], [50000, 10000], [5000, 6000])
Output11000
Example 2
Inputmax_promo_savings([500], [1000], [100])
Output0