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):
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
🌷 spike, for the 1012nd time — thank you! ♡〜٩( ˃▿˂)۶〜
Example 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).
Example 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.
Example 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.
1 ≤ edgeDeviceCost, inputPeripheralCost, bundleCost, x, y ≤ 10^9

input:
output: