C - Half and Half Editorial /

Time Limit: 2 sec / Memory Limit: 256 MB

配点 : 300300

問題文

ファーストフードチェーン「ピザアット」のメニューは「A ピザ」「B ピザ」「AB ピザ」の 33 種類です。A ピザと B ピザは全く異なるピザで、これらをそれぞれ半分に切って組み合わせたものが AB ピザです。A ピザ、B ピザ、AB ピザ 11 枚あたりの値段はそれぞれ AA 円、BB 円、CC 円です。

中橋くんは、今夜のパーティーのために A ピザ XX 枚と B ピザ YY 枚を用意する必要があります。これらのピザを入手する方法は、AA ピザや BB ピザを直接買うか、AB ピザ 22 枚を買って A ピザ 11 枚と B ピザ 11 枚に組み替える以外にはありません。このためには最小で何円が必要でしょうか?なお、ピザの組み替えにより、必要な量を超えたピザが発生しても構いません。

制約

  • 1A,B,C50001 ≤ A, B, C ≤ 5000
  • 1X,Y1051 ≤ X, Y ≤ 10^5
  • 入力中のすべての値は整数である。

入力

入力は以下の形式で標準入力から与えられる。

AA BB CC XX YY

出力

XX 枚の A ピザと YY 枚の B ピザを用意するために必要な最小の金額を出力せよ。


入力例 1Copy

Copy
1500 2000 1600 3 2

出力例 1Copy

Copy
7900

AB ピザを 44 枚買って A ピザと B ピザ 22 枚ずつに組み替え、A ピザを 11 枚買い足すのが最適です。


入力例 2Copy

Copy
1500 2000 1900 3 2

出力例 2Copy

Copy
8500

A ピザ 33 枚と B ピザ 22 枚をそのまま買うのが最適です。


入力例 3Copy

Copy
1500 2000 500 90000 100000

出力例 3Copy

Copy
100000000

AB ピザを 200000200000 枚買って A ピザと B ピザ 100000100000 枚ずつに組み替えるのが最適です。A ピザが 1000010000 枚余計にできますが、構いません。

Score : 300300 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 AA yen, BB yen and CC yen (yen is the currency of Japan), respectively.

Nakahashi needs to prepare XX A-pizzas and YY 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

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

Input

Input is given from Standard Input in the following format:

AA BB CC XX YY

Output

Print the minimum amount of money required to prepare XX A-pizzas and YY B-pizzas.


Sample Input 1Copy

Copy
1500 2000 1600 3 2

Sample Output 1Copy

Copy
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 2Copy

Copy
1500 2000 1900 3 2

Sample Output 2Copy

Copy
8500

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


Sample Input 3Copy

Copy
1500 2000 500 90000 100000

Sample Output 3Copy

Copy
100000000

It is optimal to buy 200000200000 AB-pizzas and rearrange them into 100000100000 A-pizzas and 100000100000 B-pizzas. We will have 1000010000 more A-pizzas than necessary, but that is fine.



2025-04-18 (Fri)
21:11:57 +00:00