3789. Minimum Cost to Acquire Required Items
You are given five integers
cost1,cost2,costBoth,need1, andneed2.There are three types of items available:
- An item of type 1 costs
cost1and contributes 1 unit to the type 1 requirement only.- An item of type 2 costs
cost2and contributes 1 unit to the type 2 requirement only.- An item of type 3 costs
costBothand contributes 1 unit to both type 1 and type 2 requirements.You must collect enough items so that the total contribution toward type 1 is at least
need1and the total contribution toward type 2 is at leastneed2.Return an integer representing the minimum possible total cost to achieve these requirements.
1 | class Solution { |