CF354A.Vasya and Robot

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

Vasya has nn items lying in a line. The items are consecutively numbered by numbers from 11 to nn in such a way that the leftmost item has number 11 , the rightmost item has number nn . Each item has a weight, the ii -th item weights wiw_{i} kilograms.

Vasya needs to collect all these items, however he won't do it by himself. He uses his brand new robot. The robot has two different arms — the left one and the right one. The robot can consecutively perform the following actions:

  1. Take the leftmost item with the left hand and spend wilw_{i}·l energy units ( wiw_{i} is a weight of the leftmost item, ll is some parameter). If the previous action was the same (left-hand), then the robot spends extra QlQ_{l} energy units;
  2. Take the rightmost item with the right hand and spend wjrw_{j}·r energy units ( wjw_{j} is a weight of the rightmost item, rr is some parameter). If the previous action was the same (right-hand), then the robot spends extra QrQ_{r} energy units;

Naturally, Vasya wants to program the robot in a way that the robot spends as little energy as possible. He asked you to solve this problem. Your task is to find the minimum number of energy units robot spends to collect all items.

输入格式

The first line contains five integers n,l,r,Ql,Qrn,l,r,Q_{l},Q_{r} (1<=n<=105;1<=l,r<=100;1<=Ql,Qr<=104)(1<=n<=10^{5};1<=l,r<=100;1<=Q_{l},Q_{r}<=10^{4}) .

The second line contains nn integers w1,w2,...,wnw_{1},w_{2},...,w_{n} (1<=wi<=100)(1<=w_{i}<=100) .

输出格式

In the single line print a single number — the answer to the problem.

输入输出样例

  • 输入#1

    3 4 4 19 1
    42 3 99
    

    输出#1

    576
    
  • 输入#2

    4 7 2 3 9
    1 2 3 4
    

    输出#2

    34
    

说明/提示

Consider the first sample. As l=rl=r , we can take an item in turns: first from the left side, then from the right one and last item from the left. In total the robot spends 442+499+43=5764·42+4·99+4·3=576 energy units.

The second sample. The optimal solution is to take one item from the right, then one item from the left and two items from the right. In total the robot spends (24)+(71)+(23)+(22+9)=34(2·4)+(7·1)+(2·3)+(2·2+9)=34 energy units.

首页