#P2223. [HNOI2001] 软件开发

[HNOI2001] 软件开发

Description

A software company is planning a nn-day software development schedule. According to the plan, on day ii, nin_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 AA takes aa days; method BB takes bb days. The cost of method AA is fAf_A per towel, and the cost of method BB is fBf_B per towel. Buying a new towel costs ff (a new towel is already disinfected and can be used on the same day). The manager is planning, for each of these nn days, how many new towels to buy, how many towels to send for method AA disinfection, and how many towels to send for method BB 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 AA disinfection, and how many towels to send for method BB disinfection, so that during this nn-day development period, the total cost of providing towel service is minimized.

Input Format

The first line contains six integers n,a,b,f,fA,fBn,a,b,f,f_A,f_B.

The second line contains nn integers n1,n2,,nnn_1,n_2,\ldots,n_n.

Output Format

Output a single integer, the minimal total cost.

4  1  2  3  2  1                         
8  2  1  6  

38

Hint

Constraints For 100%100\% of the testdata, it is guaranteed that b>ab>a, f>fA>fBf>f_A>f_B, 1f,fA,fB601\le f,f_A,f_B\le 60, 1n1031\le n\le 10^3.

Translated by ChatGPT 5