Minimum Energy Cost
Janet has N bags in a row. Each bag has a weight (Wi). Janet can collect bags from either the leftmost or rightmost position, but there are energy costs:
Wi) multiplied by X (if collecting from the left) or Y (if collecting from the right).El (if collected from the left side consecutively) or Er (if collected from the right side consecutively).Find the strategy that minimizes the total energy cost Janet spends to collect all the bags and display the minimum cost Bob has to pay.
Input Format
The first line of input contains five space-separated integers: N (number of bags), X, Y, El, Er (energy costs)
The second line of input contains N space-separated integers representing the weight of each bag (Wi).
Output Format
Display the minimum energy cost expenditure for Bob.
1Example 1
Constraints
Limits and guarantees your solution can rely on.
:O