Tap here to switch tabs
Problem
Submissions

Problem: Minimum Cost to Acquire Required Items

Try to solve the Minimum Cost to Acquire Required Items problem.

Statement

You are given five integers: cost1, cost2, costBoth, need1, and need2.

There are three types of items available for purchase:

  • An item of type 11 costs cost1 and provides 11 unit of type 11.

  • An item of type 22 costs cost2 and provides 11 unit of type 22.

  • An item of type 33 costs costBoth and provides 11 unit of type 11 and 11 unit of type 22.

Return the minimum total cost needed to acquire at least need1 units of type 11 and at least need2 units of type 22.

Constraints:

  • 1≤1 \leq cost1, cost2, costBoth ≤106\leq 10^6

  • 0≤0 \leq need1, need2 ≤109\leq 10^9

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Minimum Cost to Acquire Required Items

Try to solve the Minimum Cost to Acquire Required Items problem.

Statement

You are given five integers: cost1, cost2, costBoth, need1, and need2.

There are three types of items available for purchase:

  • An item of type 11 costs cost1 and provides 11 unit of type 11.

  • An item of type 22 costs cost2 and provides 11 unit of type 22.

  • An item of type 33 costs costBoth and provides 11 unit of type 11 and 11 unit of type 22.

Return the minimum total cost needed to acquire at least need1 units of type 11 and at least need2 units of type 22.

Constraints:

  • 1≤1 \leq cost1, cost2, costBoth ≤106\leq 10^6

  • 0≤0 \leq need1, need2 ≤109\leq 10^9