100952: [AtCoder]ABC095 C - Half and Half

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Score : $300$ points

Problem Statement

"Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are $A$ yen, $B$ yen and $C$ yen (yen is the currency of Japan), respectively.

Nakahashi needs to prepare $X$ A-pizzas and $Y$ B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas.

Constraints

  • $1 ≤ A, B, C ≤ 5000$
  • $1 ≤ X, Y ≤ 10^5$
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

$A$ $B$ $C$ $X$ $Y$

Output

Print the minimum amount of money required to prepare $X$ A-pizzas and $Y$ B-pizzas.


Sample Input 1

1500 2000 1600 3 2

Sample Output 1

7900

It is optimal to buy four AB-pizzas and rearrange them into two A-pizzas and two B-pizzas, then buy additional one A-pizza.


Sample Input 2

1500 2000 1900 3 2

Sample Output 2

8500

It is optimal to directly buy three A-pizzas and two B-pizzas.


Sample Input 3

1500 2000 500 90000 100000

Sample Output 3

100000000

It is optimal to buy $200000$ AB-pizzas and rearrange them into $100000$ A-pizzas and $100000$ B-pizzas. We will have $10000$ more A-pizzas than necessary, but that is fine.

Input

题意翻译

## 题目描述 快餐连锁店 “Pizza At” 提供三种披萨饼:A披萨饼、B披萨饼和AB披萨饼。 A披萨和B披萨是完全不同的披萨,AB披萨是A披萨和B披萨的**一半**结合在一起形成的。 一个A披萨、一个B披萨和一个AB披萨的价格分别是 $A$ 元、$B$ 元和 $C$ 元。 Nakahashi 需要为今晚的派对准备 $X$ 份A披萨和 $Y$ 份B披萨。他只能通过直接购买A披萨和B披萨,或者购买两个AB披萨,然后重新组合成一个A披萨和一个B披萨来获得这些披萨。 他至少需要多少钱,才能通过重新组合这些披萨得到**比需要更多**的披萨饼。 ## 输入格式 输入 $5$ 个整数 $A,B,C,X,Y$,具体含义见题面描述 ## 输出格式 输出 Nakahashi 最小需要多少钱 ## 输入输出样例 ### 输入 #1 ``` 1500 2000 1600 3 2 ``` ### 输出 #1 ``` 7900 ``` ### 输入 #2 ``` 1500 2000 1900 3 2 ``` ### 输出 #2 ``` 8500 ``` ### 输入 #3 ``` 1500 2000 500 90000 100000 ``` ### 输出 #3 ``` 100000000 ``` ## 说明/提示 ### 数据范围 $1\leq A, B, C \leq 5000$ $1\leq X, Y \leq 10^5$ 保证输入的值均为整数 ### 样例1解释 买 $4$ 张AB披萨,组合成 $2$ 张A披萨和 $2$ 张B披萨,再直接买 $1$ 张A披萨,花费的钱是最少的。 ### 样例2解释 直接买 $3$ 张A披萨和 $2$ 张B披萨最省钱。 ### 样例3解释 买 $20000$ 张AB披萨,组合成 $100000$ 张A披萨和 $10000$ 张B披萨。容易发现A披萨多了 $10000$ 张,但仍然满足条件。

加入题单

算法标签: