301870: CF354A. Vasya and Robot
Memory Limit:256 MB
Time Limit:1 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Vasya and Robot
题意翻译
有一排物品,每个物品有一个价值,机器人每次可以从左边或右边取走一个,每次消耗的能量为(l为左边,r为右边)*物品的价值.如果机器人的操作和上一步相同(都是取走左边的或者取走右边的),如果取走左边的额外消耗ql能量,取走右边的额外消耗qr能量.给出以上数据,求机器人取走所有物品消耗的最少能量.题目描述
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.输入输出格式
输入格式
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) $ .
输出格式
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