Get Minimum Cost
Problem statement
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
getMinimumCost(edgeDeviceCost: int, inputPeripheralCost: int, bundleCost: int, x: int, y: int) → long
Complete the function getMinimumCost in the editor.
getMinimumCost has the following parameter(s):
int edgeDeviceCost: the cost of an edge deviceint inputPeripheralCost: the cost of an input peripheralint bundleCost: the cost of a bundle containing both, an edge device and an input peripheralint x: the number of edge devices requiredint 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
Examples
Example 1
edgeDeviceCost = 3inputPeripheralCost = 2bundleCost = 1x = 4y = 3return = 4The 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).
Example 2
edgeDeviceCost = 1inputPeripheralCost = 20bundleCost = 5x = 9y = 1return = 13The 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.
Example 3
edgeDeviceCost = 1inputPeripheralCost = 2bundleCost = 2x = 2y = 1return = 3The 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
1 ≤ edgeDeviceCost, inputPeripheralCost, bundleCost, x, y ≤ 10^9