P2223 [HNOI2001] Software Development

Description

A software company is planning a $n$-day software development schedule. According to the plan, on day $i$, $n_i$ software developers are needed. To improve efficiency, the company provides many services for the developers. One of these services is to provide each developer with a disinfected towel every day. After being used for one day, the towel must be disinfected again before it can be used again. There are two disinfection methods. Method $A$ takes $a$ days; method $B$ takes $b$ days. The cost of method $A$ is $f_A$ per towel, and the cost of method $B$ is $f_B$ per towel. Buying a new towel costs $f$ (a new towel is already disinfected and can be used on the same day). The manager is planning, for each of these $n$ days, how many new towels to buy, how many towels to send for method $A$ disinfection, and how many towels to send for method $B$ disinfection. Of course, the manager wants to minimize the total cost. Your task is: determine, for each day, how many towels to buy, how many towels to send for method $A$ disinfection, and how many towels to send for method $B$ disinfection, so that during this $n$-day development period, the total cost of providing towel service is minimized.

Input Format

The first line contains six integers $n,a,b,f,f_A,f_B$. The second line contains $n$ integers $n_1,n_2,\ldots,n_n$.

Output Format

Output a single integer, the minimal total cost.

Explanation/Hint

Constraints For $100\%$ of the testdata, it is guaranteed that $b>a$, $f>f_A>f_B$, $1\le f,f_A,f_B\le 60$, $1\le n\le 10^3$. Translated by ChatGPT 5