#3789
Minimum Cost to Acquire Required Items
expert · 1080 · lc medium +32 · 34.8% accepted · 67 likes · top 12%
Description
Given integers cost1, cost2, costBoth, need1, and need2, purchase some combination of type-1 items (cost cost1, fulfills requirement 1 only), type-2 items (cost cost2, fulfills requirement 2 only), and type-3 items (cost costBoth, fulfills both) such that at least need1 units of requirement 1 and need2 units of requirement 2 are satisfied, and return the minimum total cost.
Code
1
2
3