FastPrepFastPrep
Problem Brief

Find Minimum Cost

OA

You are given a list of houses, such that A[k] corresponds to the amount of energy needed for house k. You will be installing two types of solar panels:

  1. Type 1: A solar panel which provides A[k] amount of power for price X.
  2. Type 2: A solar panel which provides 2 * A[k] amount of power for price Y.

Your goal is to find the minimum cost such that all houses are provided with at least their required amount of power.

Note: The power distributed from Y is not sequential, as you only focus on providing at least the net amount of energy of all the houses.

1Example 1

Input
A = [4, 3, 5, 2], X = 2, Y = 5
Output
7
Explanation
Assign solar panel type Y to A[2], which will cover A[1] and A[3], and then assign solar panel type X to A[0]. Thus the minimum cost is 5 + 2 = 7.

Constraints

Limits and guarantees your solution can rely on.

🥭🥭
public int findMinimumCost(int[] A, int X, int Y) {
  // write your code here
}
Input

A

[4, 3, 5, 2]

X

2

Y

5

Output

7

Sign in to submit your solution.