Codeforces Round 206 (Div. 1)
A
Vasya and Robot
Codeforces
1500
原题
←B →
翻译中…

Vasya has $*n*$ items lying in a line. The items are consecutively numbered by numbers from $1$ to $*n*$ in such a way that the leftmost item has number $1$, the rightmost item has number $*n*$. Each item has a weight, the $*i*$-th item weights $*w*_{*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 $*w*_{*i*} · *l*$ energy units ($*w*_{*i*}$ is a weight of the leftmost item, $*l*$ is some parameter). If the previous action was the same (left-hand), then the robot spends extra $*Q*_{*l*}$ energy units;
  2. Take the rightmost item with the right hand and spend $*w*_{*j*} · *r*$ energy units ($*w*_{*j*}$ is a weight of the rightmost item, $*r*$ is some parameter). If the previous action was the same (right-hand), then the robot spends extra $*Q*_{*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.

翻译中…

Input

翻译中…

The first line contains five integers $*n*, *l*, *r*, *Q*_{*l*}, *Q*_{*r*}$ $(1 ≤ *n* ≤ 10^{5}; 1 ≤ *l*, *r* ≤ 100; 1 ≤ *Q*_{*l*}, *Q*_{*r*} ≤ 10^{4})$.

翻译中…

The second line contains $*n*$ integers $*w*_{1}, *w*_{2}, ..., *w*_{*n*}$ $(1 ≤ *w*_{*i*} ≤ 100)$.

翻译中…

Output

翻译中…

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

翻译中…

Note

翻译中…

Consider the first sample. As $*l* = *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 $4·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 $(2·4) + (7·1) + (2·3) + (2·2 + 9) = 34$ energy units.

翻译中…

样例

Input #1
3 4 4 19 1
42 3 99
Output #1
576
InputCopy OutputCopy
Input #2
4 7 2 3 9
1 2 3 4
Output #2
34
InputCopy OutputCopy
题目信息
题号
354A
时间限制
1 s
内存限制
256 MB
标签
暴力
贪心
数学

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。