FastPrepFastPrep
Problem Brief

Get Minimum Cost

FULLTIMEOA
See IBM online assessment and hiring insights

In an edge computing environment, required hardware includes edge devices, input peripherals, and bundles that encompass both types. Each resource comes at a cost, with edge devices priced at edgeDeviceCost, peripherals at inputPeripheralCost, and bundles at bundleCost.

The challenge is to optimize the procurement of resources. The objective is to ensure the provision of the right quantities of edge devices and peripherals, allowing for a degree of flexibility, and accommodating extra equipment. This flexibility is provided to meet the requirements of the environment, which necessitates x edge devices and y peripherals. The primary goal is to minimize costs while simultaneously guaranteeing that the edge computing environment is equipped with all the essential resources. Compute and return the total expenditure.

Function Description

Complete the function getMinimumCost in the editor.

getMinimumCost has the following parameter(s):

  1. int edgeDeviceCost: the cost of an edge device
  2. int inputPeripheralCost: the cost of an input peripheral
  3. int bundleCost: the cost of a bundle containing both, an edge device and an input peripheral
  4. int x: the number of edge devices required
  5. int y: the number of input peripherals required

Returns

long: the minimum expenditure necessary to ensure that the edge computing environment fully equipped

Constraints

  • 1 ≤ edgeDeviceCost, inputPeripheralCost, bundleCost, x, y ≤ 10^9

🌷 spike, for the 1012nd time — thank you! ♡〜٩( ˃▿˂)۶〜

1Example 1

Input
edgeDeviceCost = 3, inputPeripheralCost = 2, bundleCost = 1, x = 4, y = 3
Output
4
Explanation
The optimal strategy is to buy 4 bundles for 4 units of money. This provides the environment with 4 edge devices (x ≤ 4) and 4 peripherals (y < 4).

2Example 2

Input
edgeDeviceCost = 1, inputPeripheralCost = 20, bundleCost = 5, x = 9, y = 1
Output
13
Explanation
The optimal strategy is to get 8 edge devices and 1 bundle containing both, resulting in a total cost of 13 units. The environment will have 9 edge devices and 1 peripheral.

3Example 3

Input
edgeDeviceCost = 1, inputPeripheralCost = 2, bundleCost = 2, x = 2, y = 1
Output
3
Explanation
The most cost-efficient strategy is to purchase 1 edge device and 1 bundle pack with a total of 1 + 2 = 3 units. Any other approach results in a higher cost. The min total expenditure is 3 units.

Constraints

Limits and guarantees your solution can rely on.

1 ≤ edgeDeviceCost, inputPeripheralCost, bundleCost, x, y ≤ 10^9
public long getMinimumCost(int edgeDeviceCost, int inputPeripheralCost, int bundleCost, int x, int y) {
  // write your code here
}
Input

edgeDeviceCost

3

inputPeripheralCost

2

bundleCost

1

x

4

y

3

Output

4

Sign in to submit your solution.