Problem:


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.



Sample input:
1500 2000 1600 3 2


Sample output:
7900

Submission status: Accepted

Solution code:
mod = 10 ** 9 + 7
mod2 = 2 ** 61 + 1
from collections import deque
import heapq
import time
from bisect import bisect_left, insort_left, bisect_right
import sys
import random
import itertools

input = sys.stdin.readline
_NUMINT_ALL = list(range(10))
_START_TIME = time.time()


def main():
    ans = solve()

    if ans is True or ans is False:
        YesNo(ans)
    elif ans is not None:
        print(ans)


def solve():

    A, B, C, X, Y = iip()

    ans = 0
    if A+B >= C*2:
        mxy = min(X, Y)
        X -= mxy
        Y -= mxy
        ans += C * 2 * mxy

    #print(ans, X, Y)

    if B > C*2:
        ans += C*2*Y
    else:
        ans += B*Y

    if A > C*2:
        ans += C*2*X
    else:
        ans += A*X

    print(ans)




#####################################################ライブラリ集ここから




def kiriage_warizan(a, b):
    return -(-a//b)


def iip(listed=True):  # 数字のinputをlistで受け取る
    d = input().rstrip("\n").split()
    try:
        ret = [int(i) for i in d]
    except:
        ret = [int(i) if i in _NUMINT_ALL else i for i in d]
        if len(ret) == 1 and listed is False:
            return ret[0]

    if len(ret) == 1 and not listed:
        return ret[0]
    return ret

def iipt(l, listed=True, num_only=True):  # 縦向きに並んでいるデータをリストに落とし込む(iip利用)
    ret = []
    for i in range(l):
        ret.append(iip(listed=listed))
    return ret


def saidai_kouyakusuu(A):  # 最大公約数
    l = len(A)
    while True:
        m = min(A)
        mx = max(A)
        if m == mx:
            return m

        for i in range(l):
            if A[i] % m == 0:
                A[i] = m
            else:
                A[i] %= m

def time_debug_10percent():
    a = random.randint(0, 9)
    if a == 9:
        sys.exit()

def time_debug(t):
    time.sleep(_START_TIME + t - time.time())
    sys.exit()


def make_graph_edge_flat(N):  # グラフ作成のための辺をリストで返す
    ret = []
    for i in range(N-1):
        a, b, c = iip()
        a -= 1
        b -= 1
        ret[a].append((b, c))
        ret[b].append((a, c))
    return ret


def sort_tuples(l, index):  # タプルのリストを特定のインデックスでソートする
    if isinstance(l, list):
        l.sort(key=lambda x: x[index])
        return l
    else:
        l = list(l)
        return sorted(l, key=lambda x: x[index])


def count_elements(l):  # リストの中身の個数を種類分けして辞書で返す
    d = {}
    for i in l:
        if i in d:
            d[i] += 1
        else:
            d[i] = 1
    return d


def safeget(l, index, default="exception"):  # listの中身を取り出す時、listからはみ出たり
    if index >= len(l):                      # マイナスインデックスになったりするのを防ぐ
        if default == "exception":
            raise Exception("".join(["safegetに不正な値 ", index, "が渡されました。配列の長さは", len(l), "です"]))
        else:
            return default
    elif index < 0:
        if default == "exception":
            raise Exception("".join(["safegetに不正な値 ", index, "が渡されました。負の値は許可されていません"]))
        else:
            return default
    else:
        return l[index]


def sortstr(s):  # 文字列をソートする
    return "".join(sorted(s))


def iip_ord(startcode="a"):  # 文字列を数字の列に変換する(数字と文字は1:1対応)
    if isinstance(startcode, str):
        startcode = ord(startcode)
    return [ord(i) - startcode for i in input()]


def YesNo(s):  # TrueFalseや1, 0をYesNoに変換する
    if s:
        print("Yes")
    else:
        print("No")


def fprint(s):  # リストを平たくしてprintする(二次元リストを見やすくしたりとか)
    for i in s:
        print(i)


def bitall(N):  # ビット全探索用のインデックスを出力
    ret = []
    for i in range(2 ** N):
        a = []
        for j in range(N):
            a.append(i % 2)
            i //= 2
        ret.append(a)
    return ret

def split_print_space(s):  # リストの中身をスペース区切りで出力する
    print(" ".join([str(i) for i in s]))


def split_print_enter(s):  # リストの中身を改行区切りで出力する
    print("\n".join([str(i) for i in s]))


def soinsuu_bunkai(n):  # 素因数分解
    ret = []
    for i in range(2, int(n ** 0.5) + 1):
        while n % i == 0:
            n //= i
            ret.append(i)
        if i > n:
            break
    if n != 1:
        ret.append(n)
    return ret


def conbination(n, r, mod, test=False):  # nCrをmodを使って計算する
    if n <= 0:
        return 0
    if r == 0:
        return 1
    if r < 0:
        return 0
    if r == 1:
        return n
    ret = 1
    for i in range(n - r + 1, n + 1):
        ret *= i
        ret = ret % mod

    bunbo = 1
    for i in range(1, r + 1):
        bunbo *= i
        bunbo = bunbo % mod

    ret = (ret * inv(bunbo, mod)) % mod
    if test:
        # print(f"{n}C{r} = {ret}")
        pass
    return ret


def inv(n, mod):  #  modnにおける逆元を計算
    return power(n, mod - 2)


def power(n, p, mod_=mod):  # 繰り返し二乗法でn**p % modを計算
    if p == 0:
        return 1
    if p % 2 == 0:
        return (power(n, p // 2, mod_) ** 2) % mod_
    if p % 2 == 1:
        return (n * power(n, p - 1, mod_)) % mod_


def nibutan_func(func, target, left, right, side="left"): # 関数を二分探索
    l = left
    r = right
    x = (l + r) // 2
    while r-l > 1:
        x = (l+r)//2
        if func(x) == target:
            return x
        elif func(x) > target:
            r = x
        else:
            l = x

    if side == "left" or func(x) == target:
        return l
    else:
        return r


def nibutan_list(list_, target, side="left"):  # リストを二分探索
    if not isinstance(list_, list):
        list_ = list(list_)

    l = 0
    r = len(list_)
    x = (l + r) // 2
    while r-l > 1:
        x = (l+r)//2
        if list_[x] == target:
            return x
        elif list_[x] > target:
            r = x
        else:
            l = x

    if side == "left" or list_[x] == target:
        return l
    else:
        return r


class UfTree():
    def __init__(self, maxnum):
        self.parent = list(range(maxnum))
        self._size = [1] * maxnum
        self.rank = [0] * maxnum

    def size(self, a):
        return self._size[self.root(a)]

    def root(self, a):
        rank = 0
        cur = a
        while True:
            if self.parent[cur] == cur:
                #for i in path: # 経路圧縮
                #    self.parent[i] = cur
                return cur
            else:
                self.parent[cur] = self.parent[self.parent[cur]]
                cur = self.parent[cur]
                rank += 1

    def unite(self, a, b):
        ra = self.root(a)
        rb = self.root(b)
        if ra == rb:
            return self

        self._size[ra] += self._size[rb]
        self.parent[rb] = ra
        return self

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
A,B,C,X,Y = map(int,input().split())
ans = A*X+B*Y
if X < Y:
    ans = min(ans,2*C*X+(Y-X)*B)
elif X > Y:
    ans = min(ans,2*C*Y+(X-Y)*A)
else:
    ans = min(ans,2*C*X)
ans = min(ans,2*C*max(X,Y))
print(ans)

Submission status: Accepted

Solution code:
a,b,c,x,y = map(int,input().split())
ans = x*a+y*b
for i in range(max(x,y)+1):
    p = c*i*2+max(0,x-i)*a+max(0,y-i)*b
    ans = min(ans,p)
print(ans)

Submission status: Accepted

Solution code:
A, B, C, X, Y = map(int, input().split())
ans = float('inf')
for i in range(10**5 + 1):
    price = 2*C*i + A*max(0, X - i) + B*max(0, Y - i)
    if ans > price:
        ans = price

print(ans)

Submission status: Accepted

Solution code:
A, B, C, X, Y = map(int, input().split())
ans = 0
if X <= Y:
    if A + B <= 2*C:
        ans += (A + B)*X
    else:
        ans += 2*C*X
    ans += min(B, 2*C)*(Y - X)
else:
    if A + B <= 2*C:
        ans += (A + B)*Y
    else:
        ans += 2*C*Y
    ans += min(A, 2*C)*(X - Y)

print(ans)

Submission status: Accepted

Solution code:
A,B,C,X,Y = map(int,input().split())
ans = float('inf')
for i in range(0,2*max(X+1,Y+1)):
    cnt = 0
    a = X - i//2
    b = Y - i//2
    if a<=0:
      a = 0
    if b<= 0:
      b =0
      
    cnt += (a)*A + C*i+(b)*B
    ans  = min(ans,cnt)
print(ans)

Submission status: Accepted

Solution code:
a,b,c,x,y = map(int,input().split())
p = max(x,y)
q = min(x,y)
ans = 0
if a+b>=2*c:
    if p == x:
        ans += 2*c*q + min(a,2*c)*(p-q)
    else:
        ans += 2*c*q + min(b,2*c)*(p-q)
else:
    if p == x:
        ans += (a+b)*q + min(a,2*c)*(p-q)
    else:
        ans += (a+b)*q + min(b,2*c)*(p-q)
         
print(ans)
# print(a,b,c,x,y)

Submission status: Accepted

Solution code:
A,B,C,X,Y = map(int,input().split())

ans = 10**9+7

for i in range(max(X,Y)+1):
    AB = i*2
    money = max(0,A*(X-i))+max(0,B*(Y-i))+C*AB
    ans = min(ans,money)
    
print(ans)

Submission status: Accepted

Solution code:
a,b,c,x,y = map(int,input().split())
ans = 10**19
ans = min(ans,a*x+b*y)
ans = min(ans,c*max(x,y)*2)
if x <= y:
    ans = min(ans,c*x*2+(y-x)*b)
else:
    ans = min(ans,c*y*2+(x-y)*a)
print(ans)

Submission status: Accepted

Solution code:
a,b,c,x,y = map(int,input().split())
ab = min(a+b, c*2)
if x>y:
    tmp, tmp2, tmp3 = y, (x-y)*a, (x-y)*ab
else:
    tmp, tmp2, tmp3 = x, (y-x)*b, (y-x)*ab
ans = 0
for i in range(tmp):
    ans += ab
print(ans+min(tmp2, tmp3))

Submission status: Accepted

Solution code:
import math

line = input().split()
a = int(line[0])
b = int(line[1])
c = int(line[2])
x = int(line[3])
y = int(line[4])

m = max(x, y)
price = a * x + b * y

for i in range(1 ,m + 1):
  tx = max(x - i, 0)
  ty = max(y - i, 0)  
  tprice = i * 2 * c + a * tx + b * ty
  if tprice < price:
    price = tprice

print(price)

Submission status: Accepted

Solution code:
a, b, c, x, y = map(int, input().split())

res = a*x + b*y
for i in range(1, max(x, y)+1):
    ab = i*2
    cand = ab*c + a*max(0, x-i) + b*max(0, y-i)
    
    res = min(res, cand)

print(res)

Submission status: Accepted

Solution code:
a,b,c,x,y = map(int, input().split())

mi = a*x+b*y
#ABピザを買う枚数で全探索（探索範囲に注意）
for i in range(0,200000+1,2):
	#ABピザが2i枚であるとき、AピザおよびBピザはそれぞれi枚
	#それぞれ必要な枚数
	num_a = max(x - i//2, 0)
	num_b = max(y - i//2, 0)
	price = num_a*a + num_b*b + i*c
	if price < mi:
		mi = price

print(mi)

Submission status: Accepted

Solution code:
A,B,C,X,Y = map(int,input().split())
if A+B<=2*C:
  print(X*A+Y*B)
else:
  Zmin=min(X,Y)*2
  Zmax=max(X,Y)*2
  ans=float("inf")
  for i in range(Zmin,Zmax+2,2):
    ans=min(ans,C*i+max(0,X-i//2)*A+max(0,Y-i//2)*B)
  print(ans)

Submission status: Accepted

Solution code:
A,B,C,X,Y = map(int,input().split())
ans1 = X * A + Y * B
ans2 =max(X, Y) * 2 * C
if X > Y:
    ans3 = 2 * C * Y + A * (X - Y)
else:
    ans3 = 2 * C * X + B * (Y - X)
print(min(ans1,ans2,ans3))

Submission status: Accepted

Solution code:
a,b,c,x,y=map(int,input().split())

#全部ABピザで買う
ans1=c*max(x,y)*2

#AピザX個、BピザをY個、それぞれ買う
ans2=a*x+b*y

#X、Yの少ない方までABピザを買い、足りない分を買う
if(x<=y):
  ans3=c*x*2+(y-x)*b
else:
  ans3=c*y*2+(x-y)*a

print(min(ans1,ans2,ans3))

Submission status: Accepted

Solution code:
a, b, c, x, y = map(int, input().split())
if c < (a + b) / 2:
    if (c < a and c < b) and (c * 2 <= a or c * 2 <= b):
        ans = c * 2 * max(x, y)
    else:
        ans = c * 2 * min(x, y)
        if x > y:
            ans += a * abs(y - x)
        elif x < y:
            ans += b * abs(y - x)
else:
    ans = a * x + b * y
print(ans)

Submission status: Accepted

Solution code:
a, b, c, x, y = map(int, input().split())
l = []
kari = [x, y]
kari = max(kari)*2

for i in range(kari+1):
    if i%2!=0:
        continue

    a_p = a*(x-(i//2))
    b_p = b*(y-(i//2))
    if (i//2)>=x:
        a_p = 0
    if (i//2)>=y:
        b_p = 0
        
    price = (c*i)+ a_p + b_p
    l.append(price)


print(min(l))

Submission status: Accepted

Solution code:

    
a,b,c,x,y=map(int,input().split())
d=(a+b)/2
import sys
o=x
w=y
count=0
if d>=c:
    if x>=y:
        r=x
        
        x-=y
        
        count+=(y*2*c)
        count+=((r-y)*a)
        print(min(count,o*2*c))
        sys.exit()
      

    else:
        r=y
        
        y-=x
        
        count+=(x*2*c)
  
        count+=((r-x)*b)
        
        
        print(min(count,w*2*c))
        sys.exit()
    
        
else:
    count+=(a*x+b*y)    
    print(count)

Submission status: Accepted

Solution code:
a, b, c, x, y = map(int, input().split())
# ABピザ二枚がA,B一枚づつより高いなら普通に買えばいい
if a + b < c * 2:
    print(a * x + b * y)
else:
    # A,Bの多いほうに合わせてABを買う
    MAX = max(x, y)
    MIN = min(x, y)
    isXMAX = False
    if MAX == x:
        isXMAX = True
    AllAB = MAX * c * 2
    # A,Bの少ないほうに合わせて残りは普通に買う
    DivAB = MIN * c * 2
    if isXMAX:
        DivAB += (x - y) * a
    else:
        DivAB += (y - x) * b
    print(min(AllAB, DivAB))

Submission status: Accepted

Solution code:
A,B,C,X,Y = map(int,input().split())
ans = min(A*X+B*Y,2*C*min(X,Y)+A*(X-min(X,Y))+B*(Y-min(X,Y)),2*C*max(X,Y) )
print(ans)

Submission status: Accepted

Solution code:
A, B, C, X, Y = map(int, input().split())
if A + B <= 2 * C:
    ans = A * X + B * Y
elif A + B > 2 * C:
    nokori = abs(X - Y)
    if X >= Y and A >= 2 * C:
        ans = C * 2 * X
    if Y >= X and B >= 2 * C:
        ans = C * 2 * Y
    if X >= Y and A <= 2 * C:
        ans = C * 2 * Y + nokori * A
    if Y >= X and B <= 2 * C:
        ans = C * 2 * X + nokori * B
print(ans)

Submission status: Accepted

Solution code:
a, b, c, x, y = map(int, input().split())
result = 0
if a+b > 2*c:
    if x > y:
        result += 2*c*y
        if a > 2*c:
            result += 2*c*(x-y)
        else:
            result += a*(x-y)
    else:
        result += 2*c*x
        if b > 2*c:
            result += 2*c*(y-x)
        else:
            result += b*(y-x)
else:
    result += a*x + b*y
print(result)

Submission status: Accepted

Solution code:
a,b,c,x,y = map(int, input().split())

if a+b <= 2*c:
	print(a*x + b*y)
else:
	#買えるだけABピザを買う
	z = min(x,y)
	res = c * 2 * z
	#残り
	if x>=y:
		cand1 = (x-z)*a
	else:
		cand1 = (y-z)*b
	cand2 = (max(x,y)-z)*2*c
	print(min(cand1,cand2) + res)

Submission status: Accepted

Solution code:
A, B, C, X, Y = [int(i) for i in input().split(' ') ]


BB = B if B < 2*C else 2 * C
AA = A if A < 2 * C else 2 * C



if X < Y:
    R1 = BB * (Y - X)
elif X > Y:
    R1 = AA * (X -Y)
else:
    R1 = 0

if A + B > 2 * C:
    R2 = min(X,Y) * 2 * C
else:
    R2 = min(X,Y) * (A+B)

print(R1 + R2)

Submission status: Accepted

Solution code:
# AtCoder Beginner Contest 095
# C - Half and Half
# https://atcoder.jp/contests/abc095/tasks/arc096_a

a, b, c, x, y = map(int, input().split())
mincost = 10**12

for i in range(x+y):
    cost = 2*c*i + a*max(0, x-i) + b*max(0, y-i)
    if cost < mincost:
        mincost = cost

print(mincost)

Submission status: Accepted

Solution code:
a,b,c,x,y = map(int,input().split())
ans = a * x + b * y
for i in range(1, max(x,y)+1):
    k = a*(max(0,x-i)) + b*(max(0, y-i)) + c*2*i
    ans = min(ans, k)
print(ans)

Submission status: Accepted

Solution code:
A, B, C, X, Y = map(int, input().split())

ans = 0
if (A + B) >= 2*C:
    minv = min(X, Y)
    ans += minv * 2*C
    X -= minv
    Y -= minv
    ans += min(A*X, X*2*C) + min(B*Y, Y*2*C)
    print(ans)

else:
    print(min(A*X + B*Y, max(X, Y)*2*C))

Submission status: Accepted

Solution code:
a,b,c,x,y = list(map(int, input().split()))

c = 2*c

ans = a * x + b *y
for i in range(1, max(x, y)+1):
    _ans = c * i + a * max(x-i, 0) + b * max(y-i, 0)
    ans = min(ans, _ans)
print(ans)

Submission status: Accepted

Solution code:
a,b,c,x,y = map(int,input().split())

ans = min(a*x+b*y, c*x*2+b*max(0, y-x), a*max(0, x-y)+c*y*2)
print(ans)

Submission status: Accepted

Solution code:
# ABC95_C
a,b,c,x,y = map(int,input().split())

ans = 0
if c * 2 > a + b:
    ans += a * x + b * y
else:
    if x > y:
        ans += c * 2 * y
        if a > c * 2:
            ans += (x - y) * c * 2
        else:
            ans += (x - y) * a
    else:
        ans += c * 2 * x
        if b > c * 2:
            ans += (y - x) * c * 2
        else:
            ans += (y - x) * b
        
print(ans)

Submission status: Accepted

Solution code:
a,b,c,x,y=map(int,input().split())
if a+b<=c*2:
    print(a*x+b*y)
else:
    if x<y:
        ans=c*2*x
        y-=x
        ans+=min(c*2*y,b*y)
        print(ans)
    else:
        ans=c*2*y
        x-=y
        ans+=min(c*2*x,a*x)
        print(ans)

Submission status: Accepted

Solution code:
a,b,c,x,y = map(int,input().split())
ans = 10**9
for i in range(max(x,y)+1):
	cost = c*2*i+a*max(0,x-i)+b*max(0,y-i)
	ans = min(cost,ans)
print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3

a, b, c, x, y = map(int, input().split())

# ABセットをi個購入したとき、Aをmax(0, x - i)個、Bをmax(0, y - i)個購入する必要がある
# 1 <= x, y <= 10^5なので、全探索して最小金額を求めればよい

inf = float("inf")
min_price = inf
max_i = 10 ** 5

for i in range(max_i + 1):
    rest_x, rest_y = max(0, x - i), max(0, y - i)
    price = 2 * c * i + a * rest_x + b * rest_y
    if price < min_price:
        min_price = price

print(min_price)

Submission status: Accepted

Solution code:
a,b,c,x,y = map(int,input().split())
ans = 0
if a+b > 2*c:
	ans = c*2*min(x,y)
	if x<y:
		if b > 2 * c:
			ans += 2*c*(y-x)
		else:
			ans += b*(y-x)
	else:
		if a > 2 * c:
			ans += 2*c*(x-y)
		else:
			ans += a*(x-y)
else:
	ans = a*x+b*y	
print(ans)

Submission status: Accepted

Solution code:
# AtCoder Beginner Contest 095
# C - Half and Half
# https://atcoder.jp/contests/abc095/tasks/arc096_a

a, b, c, x, y = map(int, input().split())

if a + b <= 2*c:
    print(a*x+b*y)
else:
    z = min(x, y)
    ans = 2*c*z
    x -= z
    y -= z

    if x == 0:
        if b < 2*c:
            ans += b*y
        else:
            ans += 2*c*y
    else:
        if a < 2*c:
            ans += a*x
        else:
            ans += 2*c*x
    
    print(ans)

Submission status: Accepted

Solution code:
A,B,C,X,Y=map(int,input().split())

ans1 = int(A*X + B*Y)
if X<=Y:
  ans2 = int(C*2*X + (Y-X)*B)
  ans3 = 10**10
  ans4 = int(2*Y*C)
else:
  ans2 = 10**10
  ans3 = int(C*2*Y + (X-Y)*A)
  ans4 = int(2*X*C)
  
  
print(min(ans1,ans2,ans3,ans4))

Submission status: Accepted

Solution code:
a,b,c,x,y = map(int,input().split())
ans = 0
if (a+b) >= (2*c):
  ans += 2*c*min(x,y)
  if (x > y) and (a > 2*c):
    ans += 2*c*(x-y)
  elif (x > y) and (a <= 2*c):
    ans += a*(x-y)
  elif (x < y) and (b > 2*c):
    ans += 2*c*(y-x)
  elif (x < y) and (b <= 2*c):
    ans += b*(y-x)
else:
  ans += a*x+b*y

print(ans)

Submission status: Accepted

Solution code:
import itertools
import math
import sys
import heapq
from collections import Counter
from collections import deque
from fractions import gcd
INF = 1 << 60
sys.setrecursionlimit(10 ** 6)

#ここから書き始める
a, b, c, x, y = map(int, input().split())
ans = min((a + b) * min(x, y), c * min(x, y) * 2)
if x > y:
    ans += min(a * (x - y), c * (x - y) * 2)
else:
    ans += min(b * (y - x), c * (y - x) * 2)
print(ans)

Submission status: Accepted

Solution code:
a, b, c, x, y = [int(elem) for elem in input().split()]

res = -1
for i in range(0, 10 ** 5 + 1):
  cand = i * 2 * c + max(0, x - i) * a + max(0, y - i) * b
  if res == -1:
    res = cand
  else:
    if res > cand:
      res = cand
print(res)

Submission status: Accepted

Solution code:
A,B,C,X,Y = map(int, input().split())

ABpizza = C*2
cost = 0
if ABpizza <= A+B:
    tmp = min(X,Y)
    cost = cost + ABpizza * tmp
    X = X - tmp
    Y = Y - tmp

    if (cost + X*A + Y*B) >= (cost + (max(X,Y)*ABpizza)):
        cost = cost + ((max(X,Y)*ABpizza))
    else:
        cost = (cost + X*A + Y*B)
else:
    cost = (A*X) + (B*Y)

print(cost)

Submission status: Accepted

Solution code:
a, b, c, x, y = map(int, input().split())

ans1 = (a * x) + (b * y)
if x > y:
    ans2 = c * (y * 2)
    ans2 += a * (x - y)
else:
    ans2 = c * (x * 2)
    ans2 += b * (y - x)
ans3 = c * (max(x, y) * 2)
    
print(min(ans1, ans2, ans3))

Submission status: Accepted

Solution code:
A, B, C, X, Y = map(int, input().split())

ans = A*X + B*Y
for i in range(2, 2*max(X, Y)+1, 2):
    tmp = A*(max(0, X-i//2)) + B*(max(0, Y-i//2)) + C*i
    if tmp < ans:
        ans = tmp

print(ans)

Submission status: Accepted

Solution code:
A,B,C,X,Y=map(int,input().split())

ans=A*X+B*Y
for i in range(1,max(X,Y)+1):
  if i<=X and i<=Y:
    val=A*(X-i)+B*(Y-i)+C*2*i
    ans=min(ans,val)
  elif i>X:
    val=B*(Y-i)+C*2*i
    ans=min(ans,val)
  else:
    val=A*(X-i)+C*2*i
    ans=min(ans,val)
print(ans)

Submission status: Accepted

Solution code:
a,b,c,x,y=map(int, input().split())

ans = min(a*x+b*y, c*max(x,y)*2, c*x*2+max(0,(y-x)*b), c*y*2+max(0,(x-y)*a))

print(ans)

Submission status: Accepted

Solution code:
def main():
    a, b, c, x, y = map(int, input().split())
    print(min([a*x+b*y, c*max(x, y)*2, c*x*2+max(0, (y-x)*b), c*y*2+max(0, (x-y)*a)]))

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
A, B, C, X, Y = map(int, input().split())

plan1 = A * X + B * Y
if X > Y:
    plan2 = 2 * C * X
    plan3 = 2 * C * Y + A * (X - Y)
else:
    plan2 = 2 * C * Y
    plan3 = 2 * C * X + B * (Y - X)

print(min(plan1, plan2, plan3))

Submission status: Accepted

Solution code:
a,b,c,x,y = map(int,input().split())

ans = float("inf")

for i in range(3*10**5):
    tmp = 0
    tmp += c * i
    tmp += max(a * (x - i // 2), 0)
    tmp += max(b * (y - i // 2), 0)
    ans = min(ans, tmp)
print(ans)

Submission status: Accepted

Solution code:
a,b,c,x,y=list(map(int,input().split()))
mi=min(x,y)
if a+b>=c*2:
    print(min(mi*2*c+(x-mi)*a+(y-mi)*b,c*2*max(x,y)))
else:
    print(a*x+b*y)

Submission status: Accepted

Solution code:
def main():

    a, b, c, x, y = map(int,input().split())
    ans = 0
    if a + b > c * 2:
        ans += c * 2 * min(x, y)
        if x < y:
            ab = b * (y-x)
        else:
            ab = a * (x-y)
        cc = c * 2 * max(x, y)
        ans = min(ans + ab, cc)
    else:
        ans = a * x + b * y
    print(ans)
if __name__ =='__main__':
    main()

Submission status: Accepted

Solution code:

a, b, c, x, y = map(int, input().split())
ans = 0

if a + b >= c * 2:
    if x < y:
        temp = a
        a = b
        b = temp
        temp = x
        x = y
        y = temp
    
    if a > 2 * c:
        ans = x * 2 * c
    else:
        ans = y * 2 * c + a * (x - y)
else:
    ans = a * x + b * y
print(ans)

Submission status: Accepted

Solution code:
a, b, ab, x, y = list(map(int, input().split()))

ab1 = ab * 2
abp = a + b
mins = min(x, y)
maxs = max(x, y)
nedan = min(ab1, abp) * mins

x -= mins
y -= mins
nedan_abp = x * a + y * b
nedan_ab = (maxs - mins) * ab1

if nedan_abp > nedan_ab:
  nedan += nedan_ab
else:
  nedan += nedan_abp
  
print(nedan)

Submission status: Accepted

Solution code:
# Problem C - Half and Half

# input
A, B, C, X, Y = map(int, input().split())

# initialization
min_count = min(X, Y)
max_count = max(X, Y)
dp = [0] * (max_count + 1)

# dynamic programming
for i in range(1, min_count+1):
    dp[i] = min(A+B+dp[i-1], C*2+dp[i-1])

if X>Y:
    for i in range(min_count+1, max_count+1):
        dp[i] = min(A+dp[i-1], C*2+dp[i-1])
elif Y>X:
    for i in range(min_count+1, max_count+1):
        dp[i] = min(B+dp[i-1], C*2+dp[i-1])

# output
print(dp[max_count])

Submission status: Accepted

Solution code:

def resolve():
    A, B, C, X, Y = map(int, input().split())

    yen = 0
    if A - C + B - C > 0:
        yen += C * 2 * min(X, Y)

        minans = 10 ** 30
        rest = max(X, Y) - min(X, Y)
        for i in range(rest + 1):
            if X > Y:
                minans = min((C*2 * i + (rest - i) * A), minans)
            else:
                minans = min((C*2 * i + (rest - i) * B), minans)

        yen += minans

    else:
        yen = A * X + B * Y

    print(yen)


resolve()

Submission status: Accepted

Solution code:
a,b,c,x,y = map(int,input().split())
cx,cy = 0,0
ans = 0

a1 = a*x+b*y
if x<y:
    a2 = 2*c*x + b*(y-x)
else:
    a2 = 2*c*y + a*abs(y-x)
a3 = c*max(x,y)*2
print(min([a1,a2,a3]))

Submission status: Accepted

Solution code:
a,b,c,x,y = map(int,input().split())
ans = x*a+y*b

if x < y:
    res = x*c*2+(y-x)*b
    ans = min(res,ans)
else:
    res = y*c*2+(x-y)*a
    ans = min(res,ans)
ans = min(ans,c*max(x,y)*2)
print(ans)

Submission status: Accepted

Solution code:
A, B, C, X, Y = map(int, input().split())
ans = 0
ans = A * X + B * Y
tmp_ans = C * (X + Y) * 2
if tmp_ans < ans:
    ans = tmp_ans

tmp_ans = (Y * 2) * C
tmp_ans += max((X - Y), 0) * A
if tmp_ans < ans:
    ans = tmp_ans

tmp_ans = (X * 2) * C
tmp_ans += max((Y - X), 0) * B
if tmp_ans < ans:
    ans = tmp_ans
print(ans)

Submission status: Accepted

Solution code:
a,b,c,x,y=map(int,input().split())
ans=0
ans1=0

e=max(x,y)
ans1=e*(2*c)
if 2*c<a+b:
    d=min(x,y)
    ans+=c*(2*d)
    x-=d
    y-=d
else:
    ans=a*x+b*y
    x-=x
    y-=y
ans+=x*a
ans+=y*b
print(min(ans,ans1))

Submission status: Accepted

Solution code:
a, b, c, x, y = map(int, input().split())
ans = 0
r = min(x, y)

if a + b > 2 * c:
    ans += (2 * c) * r
    x -= r
    y -= r
if a > 2 * c and x > 0:
    ans += (2 * c) * x
    y -= x
    x = 0
if b > 2 * c and y > 0:
    ans += (2 * c) * y
    x -= y
    y = 0
if x > 0:
    ans += a * x
if y > 0:
    ans += b * y
print(ans)

Submission status: Accepted

Solution code:
A, B, C, X, Y = map(int, input().split())

ab = A * X + B * Y
Ab = C * X * 2 + B * (Y-X if Y > X else 0)
aB = C * Y * 2 + A * (X -Y if X > Y else 0)
print(min(ab, Ab, aB))

Submission status: Accepted

Solution code:
a,b,c,x,y = map(int,input().split())
price1 = 0
price2 = 0
price = 0
if (a+b) >= c*2:
    price1 += min(x,y) * 2 * c
    if min(x,y)==x:
        price1 += (y-x)*b
    else:
        price1 += (x-y)*a
        
    price2 += c * max(x,y) *2
    price = min(price1,price2)
else:
    price += (a*x + b*y)
print(price)

Submission status: Accepted

Solution code:
a, b, c, x, y = map(int, input().split())

ans = 10 ** 18
for i in range(0, 2 * max(x, y) + 1, 2):
    tmp = i * c
    if x - i // 2 > 0:
        tmp += (x - i // 2) * a
    if y - i // 2 > 0:
        tmp += (y - i // 2) * b
    ans = min(ans, tmp)
print(ans)

Submission status: Accepted

Solution code:
A,B,C,X,Y=map(int,input().split())
if X>=Y:
	Z=A*(X-Y)
else:
	Z=B*(Y-X)
print(min(A*X+B*Y,min(X,Y)*2*C+Z,C*max(X,Y)*2))

Submission status: Accepted

Solution code:
a,b,c,x,y=map(int,input().split())
ans=0
if a+b>c*2:
    z=min(x,y)
    ans+=z*c*2
    x-=z
    y-=z

if a>c*2:
    ans+=x*c*2
    x=0
    y=max(0,y-x)
if b>c*2:
    ans+=y*c*2
    y=0
    x=max(0,x-y)
ans+=x*a
ans+=y*b


print(ans)

Submission status: Accepted

Solution code:
def main():
    a, b, c, x, y = (int(i) for i in input().split())
    ans = a*x + b*y
    cur = 2*c*min(x, y) + (a*(x-y) if x > y else b*(y-x))
    ans = min(ans, cur)
    cur = 2*c*max(x, y)
    ans = min(ans, cur)
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
a, b, c, x, y = map(int, input().split())
ans = 0
if a+b >= 2*c:
    if x >= y:
        ans += 2*c*y
        ans += min(a, 2*c)*(x-y)
    else:
        ans += 2*c*x
        ans += min(b, 2*c)*(y-x)
else:
    ans = x*a+y*b
print(ans)

Submission status: Accepted

Solution code:
a,b,c,x,y=map(int, input().split())
c*=2
ans=10**9
for cc in range(max(x,y)+1):
    tmp = cc * c
    tmp += max(0, x-cc)*a
    tmp += max(0, y-cc)*b
    ans = min(ans, tmp)
print(ans)

Submission status: Accepted

Solution code:
A,B,C,X,Y = map(int,input().split())
m = max(X,Y)
ans = float('inf')
for i in range(m+1):
    p = i*2*C + max(0,(X-i)*A) + max(0,(Y-i)*B)
    ans = min(ans, p)
print(ans)

Submission status: Accepted

Solution code:
A, B, C, X, Y = map(int, input().split())
ans = float('inf')
for i in range(2*10**5+1):
    price = C * i + max(0, X - i // 2) * A + max(0, Y - i // 2) * B
    ans = min(ans, price)
print(ans)

Submission status: Accepted

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 0, 1, -1, 1, -1, -1, 1]
dy = [1, -1, 0, 0, 1, -1, 1, -1]

a, b, c, x, y = MAP()
if c * 2 > a + b:
    print(a * x + b * y)
else:
    mn = min(x, y)
    mx = max(x, y)
    if x >= y:
        print(min(mn * c * 2 + (x - mn) * a, mx * c * 2))
    else:
        print(min(mn * c * 2 + (y - mn) * b, mx * c * 2))

Submission status: Accepted

Solution code:
A, B, C, X, Y = map(int, input().split())

ans = 10**18
for ab in range(max(X, Y) * 2 + 10):
    a = max(0, X - ab // 2)
    b = max(0, Y - ab // 2)
    ans = min(ans, A * a + B * b + C * ab)
print(ans)

Submission status: Accepted

Solution code:
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.buffer.readline().split()]
def I(): return int(sys.stdin.buffer.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    a,b,c,x,y = LI()
    ans = a*x+b*y
    for z in range(x+y+1):
        rx = max(0,x-z)
        ry = max(0,y-z)
        m = rx*a+ry*b+2*z*c
        if m < ans:
            ans = m
    print(ans)
    return

#Solve
if __name__ == "__main__":
    solve()