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.

Solution (Python):


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

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

print(ans)

Solution (Python):
a, b, c, x, y = map(int, input().split())
ans = []

for i in range(max(x+1, y+1)):
    tmp = c*i*2
    if i < x:
        tmp += a*(x-i)
    if i < y:
        tmp += b*(y-i)
    ans.append(tmp)

print(min(ans))

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

price1 = a*x + b*y


if(x>y):
    price2 = y*2*c + (x-y)*a
    price3 = x*2*c
else:
    price2 = x*2*c + (y-x)*b
    price3 = y*2*c

print(min(price1,price2,price3))

Solution (Python):
a,b,c,x,y = map(int,input().split())
money1=a*x+b*y
money2=a*(x-min(x,y))+b*(y-min(x,y))+c*2*min(x,y)
money3=max(x,y)*c*2
print(min(money1,money2,money3))

Solution (Python):


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

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

print(ans)

Solution (Python):

from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LS()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007


def A():
    return


def B():
    return


def C():
    return


def D():
    return


def E():
    return


def F():
    a,b,c,X,Y = LI()
    ans = float("inf")
    for z in range(300001):
        if z%2 == 0:
            m = c*z
            x = z//2
            y = z//2
            m += a*max(0,X-x)
            m += b*max(0,Y-y)
            if m < ans:
                ans = m
    print(ans)
    return


def G():
    n = I()
    x = LI()
    f = [(i,x[i]) for i in range(n)]
    f.sort(key = lambda x:x[1])
    g = [(f[i][0],i) for i in range(n)]
    g.sort(key = lambda x:x[0])
    for i in range(n):
        if g[i][1] < n//2:
            print(f[n//2][1])
        else:
            print(f[n//2-1][1])
    return


def H():
    return


def I_():
    return


def J():
    return


if __name__ == "__main__":
    F()

Solution (Python):
import numpy as np

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

value = [A, B]
n_pizza = [X, Y]



price_1 = A * X + B * Y

price_2 = 2 * C * max(X, Y)

idx_more_to_buy = n_pizza.index(max(n_pizza))
price_3 = 2 * C * min(X, Y) + value[idx_more_to_buy] * (n_pizza[idx_more_to_buy] - min(X, Y))

ans = min(price_1, price_2, price_3)
print(ans)

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

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

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

p1 = A * X + B * Y
p2 = max(X, Y) * 2 * C
p3 = min(X, Y) * 2 * C + ((Y - X) * B if (X < Y) else (X - Y) * A)

print(min([p1, p2, p3]))

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


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

print(ans)

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


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

print(ans)

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

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

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

ans=a*x+b*y
for ci in range(max(x,y)+1):
    sumc = 2*ci*c
    sumc += (x-ci)*a if (x-ci)>0 else 0
    sumc += (y-ci)*b if (y-ci)>0 else 0
    ans=min(ans,sumc)

print(ans)

Solution (Python):

import sys
from collections.abc import Iterable
from math import *
from itertools import *
from collections import *
from functools import *
from operator import *
try:
    from math import gcd
except Exception:
    from fractions import gcd


def solve(A: int, B: int, C: int, X: int, Y: int):
    a = A * X + B * Y
    minv = min(X, Y)
    b = C * 2 * minv + A * (X - minv) + B * (Y - minv)
    c = 2 * max(X, Y) * C

    return min(a, b, c)


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  
    B = int(next(tokens))  
    C = int(next(tokens))  
    X = int(next(tokens))  
    Y = int(next(tokens))  
    result = solve(A, B, C, X, Y)
    if isinstance(result, Iterable):
        result = '\n'.join([str(v) for v in result])
    print(result)

if __name__ == '__main__':
    main()

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

if (A+B)/2 >= C and X >= Y:
  print(Y*2*C+A*(X-Y) if A*(X-Y)<2*C*(X-Y) else X*2*C)
elif (A+B)/2 >= C and Y >= X:
  print(X*2*C+B*(Y-X) if B*(Y-X)<2*C*(Y-X) else Y*2*C)
else:
  print(A*X+B*Y)

Solution (Python):
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    a,b,c, x,y = f()
    ans = 0
    if 2*c <= a+b:
        ans += 2*c*min(x,y)
    else:
        ans += (a+b)*min(x,y)
    
    mxy = min(x,y)
    x -= mxy
    y -= mxy

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


solve()

Solution (Python):
def main():
    a_price, b_price, ab_price, a_num, b_num = map(int, input().split())
    chukan_price = (a_price + b_price) / 2
    min_num = min(a_num, b_num)

    ans = 0

    if chukan_price > ab_price:
        ans += min_num * 2 * ab_price
        a_num -= min_num
        b_num -= min_num
        
        if a_price > 2 * ab_price:
            ans += a_num * 2 * ab_price
        else:
            ans += a_num * a_price
        if b_price > 2 * ab_price:
            ans += b_num * 2 * ab_price
        else:
            ans += b_num * b_price
    else:
        ans += a_num * a_price
        ans += b_num * b_price

    print(ans)


if __name__ == '__main__':
    main()

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

Solution (Python):
import itertools
A,B,C,X, Y = list(map(int,input().split(" ")))
C2 = C * 2
ans = 0

if A+ B > C2:
    c = min(X,Y)
    ans += min(X,Y) * C2
    X -= c
    Y -= c



if A > C2:
    if B < C2:
        b_maisu = max(0,Y-X)
        ans += (X *  C2) + b_maisu * B


    else:
        ans += (max(X,Y)*C2)

elif A < C2:
    if B < C2:
        ans += A*X + Y * B
    else:
        a_maisu = max(0,X-Y)
        ans += (Y *  C2) + a_maisu * A

print(ans)

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

ave = (A+B)//2


ans1 = A*X + B * Y

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

ans3 = max(X,Y)*C*2

print(min(ans1,ans2,ans3))

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

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

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

price1 = a*x+b*y

if x <= y:
    price2 = c*x*2 + (y-x)*b
else:
    price2 = c*y*2 + (x-y)*a

price3 = max(x,y)*2*c

print(min(price1,price2,price3))

Solution (Python):
A,B,C,X,Y = map(int,input().split(' '))
MIN = float('inf')

for i in range(0,2*max(X,Y)):
  sum = C*2*i + max(0,X-i)*A + max(0,Y-i)*B
  MIN = min(MIN,sum)
print(MIN)

Solution (Python):
import sys
input = sys.stdin.readline

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

m = 10 ** 18

for i in range(max(X, Y) + 1):
    a = A * (X - i)
    b = B * (Y - i)
    c = C * i * 2

    point = 0
    for v in [a, b, c]:
        if v > 0:
            point += v

    m = min(m, point)

print(m)

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

MA, MI = max(X,Y), min(X,Y)
ans = 2 * C * MA

if X != Y:
    for i in range(MA-MI):
        if X > Y:
            tmp = ans - 2*C + A
        else:
            tmp = ans - 2*C + B
        ans = min(ans,tmp)
        
for j in range(MI):
    tmp = ans - 2*C + A + B
    ans = min(ans,tmp)

print(ans)

Solution (Python):


def read_input():
    a, b, c, x, y = map(int, input().split())
    return a, b, c, x, y


def submit():
    a, b, c, x, y = read_input()


    
    p1 = 0
    if x < y:
        ab_n = 2 * x
        b_n = y - x
        p1 = b*b_n + ab_n*c
    else:
        ab_n = 2 * y
        a_n = x - y
        p1 = a*a_n + ab_n*c

    
    p2 = a*x + b*y

    
    p3 = c * max(x, y)*2

    print(min(p1, p2, p3))

if __name__ == '__main__':
    submit()

Solution (Python):
from math import ceil
A, B, C, X, Y = map(int, input().split())
ans = float('inf')

ans = min(ans, A * X + B * Y)
ans = min(ans, C * max(X, Y) * 2)

if X > Y:
    num = 2 * Y
    ans = min(ans, num * C + ceil(X - Y) * A)
else:
    num = 2 * X
    ans = min(ans, num * C + ceil(Y - X) * B)
print(ans)

Solution (Python):
A, B, C, X, Y = map(int, input().split())
if A+B <= 2*C:
    ans = A*X+B*Y
else:
    c = min(X, Y)
    x = X-c
    y = Y-c
    ans = 2*C*c +min(A*x+B*y, 2*C*x+2*C*y)
print(ans)

Solution (Python):
A, B, C, X, Y = map(int,input().split())
pattern1 = X*A + Y *B
pattern2 = X*(C*2) + B*(max(0,Y-X))
pattern3 = A*(max(0,X-Y)) + Y*(C*2)
print(min(pattern1,pattern2,pattern3))

Solution (Python):
A,B,C,X,Y = map(int,input().split(" "))
Z = max(X,Y)
o = Z * 2 * C
for z in range(Z+1):
    x = max(X-z,0)
    y = max(Y-z,0)
    o = min(x*A+y*B+z*2*C,o)

print(o)

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

Solution (Python):
a, b, c, x, y = map(int, input().split())
c2 = min(c * 2, a + b)
a = min(a, c * 2)
b = min(b, c * 2)
ans = 0


nab = min(x, y)
ans += nab*c2
x -= nab
y -= nab



ans += x * a
ans += y * b
print(ans)

Solution (Python):
A, B, C, X, Y = map(int, input().split())
AB = min(C*2,A+B)
A = min(A, C*2)
B = min(B, C*2)
ret = 0
while X + Y > 0:
	if X > 0 and Y > 0:
		ret += AB
		X -= 1
		Y -= 1
	elif X > 0:
		ret += A
		X -= 1
	elif Y > 0:
		ret += B
		Y -= 1
print(ret)

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

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

min_price = 2 * 5000 * 100000
for nab in range(0, 2 * max(x, y) + 1, 2):
    na = max(0, x - nab // 2)
    nb = max(0, y - nab // 2)
    min_price = min(min_price, nab * c + na * a + nb * b)

print(min_price)

Solution (Python):
a, b, c, x, y = (int(i) for i in input().split())

tmp1,tmp2,tmp3 = 0,0,0

if x > y:
    tmp1 = y*2*c+(x-y)*a
    tmp3 = x*2*c
else:
    tmp1 = x*2*c+(y-x)*b
    tmp3 = y*2*c

tmp2 = a*x+b*y

print(min(tmp1,tmp2,tmp3))

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

Solution (Python):
a,b,c,x,y=map(int,input().split())
X=x
Y=y
MIN=10**9
while True:
    sum_=a*x+b*y+2*c*(max(X-x,Y-y))
    MIN=min(MIN,sum_)
    if x==0 and y==0:
        break
    if x>0:
        x-=1
    else:
        x=0
    if y>0:
        y-=1
    else:
        y=0
print(MIN)

Solution (Python):
A,B,C,X,Y=map(int,input().split())
if A+B<=2*C:
    print(X*A+Y*B)
    quit()
mi=min(X,Y)
X-=mi
Y-=mi
if X:
    print(mi*C*2+X*min(2*C,A))
else:
    print(mi*2*C+Y*min(2*C,B))

Solution (Python):
A,B,C,X,Y = map(int, input().split())
AB = 2 * C
mn = AB * max(X, Y)
for i in range(max(X, Y) + 1):
  mn = min(mn, A * max(0, X - i) + B * max(0, Y - i) + AB * i)
print(mn)

Solution (Python):
a, b, c, x, y = map(int, input().split())
d = []
for num_c in range(max(x, y)+1):
    money = num_c * 2 * c + max(x-num_c, 0) * a + max(y-num_c, 0) * b
    d.append(money)
print(min(d))

Solution (Python):
A,B,C,X,Y = [int(x) for x in input().split()]
ans = 10**15
ans = min(ans,X*A+Y*B)
if(X<Y):
    ans = min(ans,2*X*C+(Y-X)*B)
else:
    ans = min(ans,2*Y*C+(X-Y)*A)
ans = min(ans,2*max(X,Y)*C)
print(ans)

Solution (Python):
A, B, C, X, Y = map(int, input().split())
ans_list = []
for i in range(1000001):
    ans_list.append(2*i*C + max(0, X-i)*A + max(0, Y-i)*B)
print(min(ans_list))

Solution (Python):
def main():
	A, B, C, X, Y = map(int, input().split())
	max_num_c = max(X, Y)*2

	ans = A*X+B*Y
	for num_c in range(0, max_num_c+1, 2):
		num_a = max(0, X-num_c//2)
		num_b = max(0, Y-num_c//2)
		current = A*num_a+B*num_b+C*num_c
		ans = min(ans, current)

	print(ans)

if __name__ == '__main__':
    main()

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

if A+B <= 2*C:
    print(A*X + B*Y)
    exit()
else:
    cnt = 0
    if X >= Y:
        cnt += 2*C*Y
        X -= Y
        if A >= 2*C:
            cnt += 2*X*C
        else:
            cnt += X*A
    else:
        cnt += 2*C*X
        Y -= X
        if B >= 2*C:
            cnt += 2*Y*C
        else:
            cnt += Y*B
print(cnt)

Solution (Python):
def pricing(A, B, C, tmp):
    A_price = tmp * A
    B_price = tmp * B
    AnB_price = A_price + B_price
    AB_price = tmp * 2 * C
    price = AnB_price if AnB_price < AB_price else AB_price
    return price


A, B, C, X, Y = map(int, input().split())
tmp = min(X, Y)
price = pricing(A, B, C, tmp)

tmp = max(X, Y) - tmp
if X > Y:
    price += pricing(A, 0, C, tmp)
else:
    price += pricing(0, B, C, tmp)

print(price)

Solution (Python):
def pricing(A, B, C, tmp):
    A_price = tmp * A
    B_price = tmp * B
    AnB_price = A_price + B_price
    AB_price = tmp * 2 * C
    price = AnB_price if AnB_price < AB_price else AB_price
    return price


A, B, C, X, Y = map(int, input().split())
ans = 0
tmp = min(X, Y)
price = pricing(A, B, C, tmp)

if X > Y:
    tmp = max(X, Y) - tmp
    price += pricing(A, 0, C, tmp)
else:
    tmp = max(X, Y) - tmp
    price += pricing(0, B, C, tmp)

print(price)

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


bill_ab = a * x + b * y


if x <= y:
  bill_abc = x * 2*c + (y - x) * b
else:
  bill_abc = y * 2*c + (x - y) * a

bill_c = max(x,y) * 2*c


print(min(bill_ab, bill_abc, bill_c))

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

Solution (Python):
a,b,c,x,y=map(int,input().split())
print(min(max(x,y)*2*c,a*x+b*y,min(x,y)*2*c+a*(x-min(x,y))+(b*(y-min(x,y)))))

Solution (Python):
A, B, C, X, Y = map(int, input().split())
K = max(X, Y)
sum = 10 ** 12

for i in range(K+1):
    sum = min(sum, 2*C*i + max(0, X-i)*A + max(0, Y-i)*B)

print(sum)

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

while X > 0 or Y > 0:
    if X > 0 and Y > 0:
        if A + B > 2 * C:
            sum += 2 * C
        else:
            sum += A + B
        X -= 1
        Y -= 1
    else:
        if X > 0:
            if A > 2 * C:
                sum += 2 * C
            else:
                sum += A
            X -= 1
        else:
            if B > 2 * C:
                sum += 2 * C
            else:
                sum += B
            Y -= 1

print(sum)

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

while X > 0 or Y > 0:
    if X > 0 and Y > 0:
        if A + B > 2 * C:
            sum += 2 * C
            X -= 1
            Y -= 1
        else:
            sum += A + B
            X -= 1
            Y -= 1
    else:
        if X > 0:
            if A > 2 * C:
                sum += 2 * C
                X -= 1
                Y -= 1
            else:
                sum += A
                X -= 1
        else:
            if B > 2 * C:
                sum += 2 * C
                X -= 1
                Y -= 1
            else:
                sum += B
                Y -= 1

print(sum)

Solution (Python):

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

Solution (Python):


A, B, C, X, Y = map(int, input().split())
pt1 =(A*X)+(B*Y)
pt2 = 2*C*max(X,Y)
pt3 = 2*C*min(X,Y)+((A*(X-Y)) if X>Y else B*(Y-X))

print(min(pt1,pt2,pt3))

Solution (Python):


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

ans = 0

pt1 =(A*X)+(B*Y)
pt2 = 2*C*max(X,Y)
pt3 = 2*C*min(X,Y)+((A*(X-Y)) if X>Y else B*(Y-X))

print(min(pt1,pt2,pt3))

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

if A+B <= 2*C:
    answer = A * X + B * Y
else:
    answer = C * min(X, Y) * 2
    if X < Y:
        answer += min(B, C * 2) * (Y - X)
    else:
        answer += min(A, C * 2) * (X -Y)

print(answer)

Solution (Python):

import sys
INF = float("inf")


def solve(A: int, B: int, C: int, X: int, Y: int):
    ans = 0
    if 2*C < A+B:     
        ge = min(X, Y)
        ans += C*2*ge
        X -= ge
        Y -= ge

    if X > 0:                   
        if 2*C < A:
            ans += C*2*X
        else:
            ans += A*X
    if Y > 0:
        if 2*C < B:
            ans += C*2*Y
        else:
            ans += B*Y
    print(ans)

    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  
    B = int(next(tokens))  
    C = int(next(tokens))  
    X = int(next(tokens))  
    Y = int(next(tokens))  
    solve(A, B, C, X, Y)


if __name__ == '__main__':
    main()

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

ans = 10**9
for i in range(max(X, Y)+1):
    price = 2*C*i
    p_A, p_B = X, Y
    p_A -= i
    p_B -= i
    if p_A > 0:
        price += p_A*A
    if p_B > 0:
        price += p_B*B
    ans = min(ans, price)

print(ans)

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

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

if A+B < 2*C:
    print(A*X + B*Y)
else:
    ans = 0
    num = 0
    if X < Y:
        ans += 2 * C * X
        num = Y - X
        if B > 2*C:
            ans += 2 * C * num
        else:
            ans += B * num
    else:
        ans += 2 * C * Y
        num = X - Y
        if A > 2*C:
            ans += 2 * C * num
        else:
            ans += A * num
    print(ans)

Solution (Python):
def f():
    if (A+B) <= C*2:
        return A*X+B*Y
    elif X==Y:
        return X*C*2
    else:
        if X > Y:
            if A > C*2:
                return (C*2)*(X-Y)+Y*C*2
            return A*(X-Y)+Y*C*2
        else:
            if B > C*2:
                return (C*2)*(Y-X)+X*C*2
            return B*(Y-X)+X*C*2
A,B,C,X,Y = map(int,input().split())
print(f())

Solution (Python):
def f():
    if (A+B) <= C*2:
        return A*X+B*Y
    elif X==Y:
        return X*C*2
    else:
        if X > Y:
            if A > C*2:
                return (C*2)*(X-Y)+Y*C*2
            return A*(X-Y)+Y*C*2
        else:
            if B > C*2:
                return (C*2)*(Y-X)+X*C*2
            return B*(Y-X)+X*C*2
A,B,C,X,Y = map(int,input().split())
print(f())

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

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

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

if A+B<=2*C:
    ans=A*X+B*Y

elif X<=Y:
    ans=2*X*C
    Y-=X
    ans+=min(2*Y*C,Y*B)

elif X>Y:
    ans=2*Y*C
    X-=Y
    ans+=min(2*X*C,X*A)

print(ans)

Solution (Python):
A,B,C,X,Y = map(int,input().split())
ans = 10**10
for c in range(max(X,Y)+1):
    ans = min(ans,C*2*c + A*max(0,X-c) + B*max(0,Y-c))
print(ans)

Solution (Python):
a, b, c, x, y = map(int, input().split())
ans = float('inf')

for i in range(100005):
    tmp = i * 2 * c
    tmp += max(0, x-i) * a
    tmp += max(0, y-i) * b
    ans = min(ans, tmp)

print(ans)

Solution (Python):
a, b, c, x, y = map(int, input().split())
ans = float('inf')

for i in range(200005):
    tmp = i * 2 * c
    tmp += max(0, x-i) * a
    tmp += max(0, y-i) * b
    ans = min(ans, tmp)

print(ans)

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

ans = 0

if a + b <= 2*c:
    ans = a*x + b*y

elif a >= c*2 and b >= c*2:
    ans = c * max(x,y) * 2
elif a < c*2 and b >= c*2:
    ans = c*y*2 + max(0, x-y) * a
elif a >= c*2 and b < c*2:
    ans = c*x*2 + max(0, y-x) * b
else:
    ans = min(x, y) * 2 * c + a * (x-min(x,y)) + b * (y-min(x, y))

print(ans)

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

print(ans)

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

if A+B <= 2*C:
    ans = A*X + B*Y
else:
    if X < Y:
        A, B, X, Y = B, A, Y, X
    ans = min(C*2*Y + A*(X-Y), C*2*X)

print(ans)

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

min_cost = A*X + B*Y
for i in range(1, 1+max(X,Y)):
  cost = i*C*2 + max(0,X-i)*A + max(0,Y-i)*B
  min_cost = min(min_cost, cost)

print(min_cost)

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

Solution (Python):
A,B,C,X,Y=map(int,input().split())
ans=[]
ans.append(max([X,Y])*2*C)
ans.append(A*X+B*Y)
t=min([X,Y])*2*C
if X>=Y:
  t+=(X-Y)*A
else:
  t+=(Y-X)*B
ans.append(t)
print(min(ans))

Solution (Python):



A, B, AB, num_A, num_B = map(int, input().rstrip().split(' '))

min_cost = A * num_A + B * num_B
min_cost = min(min_cost, AB * 2 * max(num_A, num_B))
if num_A == num_B:
    min_cost = min(min_cost, AB * (num_A + num_B))
elif num_A > num_B:
    min_cost = min(min_cost, A * (num_A - num_B) + AB * 2 * num_B)
elif num_A < num_B:
    min_cost = min(min_cost, B * (num_B - num_A) + AB * 2 * num_A)
    
print(min_cost)

Solution (Python):
A, B, C, X, Y = map(int, input().split())
money = min(X, Y) * min(A + B, 2*C)
money += min(A*(X - min(X, Y)) + B*(Y - min(X, Y)), 2*C*abs(X - Y))
print(money)

Solution (Python):



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

minprice = float("inf")

for i in range(1000001):
    buya = max(0,x - int(i / 2))
    buyb = max(0,y - int(i / 2))
    buyc = i
    price = buya * a + buyb * b + buyc * c
    if price < minprice:
        minprice = price

print(minprice)

Solution (Python):
a,b,c,x,y = map(int,input().split())
mo=[a,b]
if(a+b>2*c):
    sum=2*min(x,y)*c+max(x-y,y-x)*min(2*c,mo[x<=y])
else:
    sum=a*x+b*y
print(sum)

Solution (Python):
A, B, C, X, Y = map(int, input().split())
ans = 10**18
if Y < X:
    t = X
    X = Y
    Y = t
    t = A
    A = B
    B = t
for i in range(2 * Y + 1):
    if i % 2:
        continue
    x, y = max(0, X - i//2), max(0, Y - i//2)
    sub = C * i + A * x + B * y
    if sub < ans:
        ans = sub
print(ans)

Solution (Python):
a,b,c,x,y=map(int,input().split())
p1=a*x+b*y
p2=x*c*2
if x<y:
  p2+=(y-x)*b
p3=y*c*2
if y<x:
  p3+=(x-y)*a
p4=c*max(x,y)*2
print(min(p1,p2,p3,p4))

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


ans1=max(x,y)*2*c

ans2=x*2*c+max(y-x,0)*b

ans3=y*2*c+max(x-y,0)*a

ans4=a*x+b*y
print(min(ans1,ans2,ans3,ans4))

Solution (Python):

A,B,C,X,Y =map(int,input().split())
honest = A * X + B * Y

if X >= Y:
    diff = C * min(X,Y) * 2 + A * (X-Y)
else:
    diff = C * min(X,Y) * 2 + B * (Y -X)
max_ =C * max(X,Y) * 2

print(min(honest,diff,max_))

Solution (Python):
a,b,ab,x,y=map(int, input().split())
if(a+b<=2*ab ):
  ans=a*x+b*y
elif(a>=2*ab and b>=2*ab):
  ans=max(x,y)*2*ab
elif(a>=2*ab):
  if(x<=y):
    ans=ab*2*x+b*(y-x)
  else:
    ans=ab*2*x
elif(b>=2*ab):
  if(x<=y):
    ans=ab*2*y
  else:
    ans=ab*2*y+a*(x-y)
elif(a+b>=2*ab):
  if(x<=y):
    ans=ab*2*x+b*(y-x)
  else:
    ans=ab*2*y+a*(x-y)
print(ans)

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

Solution (Python):
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, OrderedDict
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from math import ceil, floor
from sys import setrecursionlimit

import heapq
import itertools
import operator


inf = float('inf')



A, B, C, X, Y = 0, 0, 0, 0, 0


def set_inputs():
    global A, B, C, X, Y
    A, B, C, X, Y = get_li()
    return


def main():
    setrecursionlimit(100000)
    set_inputs()
    
    if 2 * C <= A + B:
        a = min(A, 2 * C)
        b = min(B, 2 * C)
        print(min(X, Y) * 2 * C + max(0, X - min(X, Y)) * a + max(0, Y - min(X, Y)) * b)
    else:
        print(A * X + B * Y)
    return
    
    
    
    
    
    
    
    
    
    
    
    
    


def get_int():
    return int(input())


def get_float():
    return float(input())


def get_str():
    return input().strip()


def get_li():
    return [int(i) for i in input().split()]


def get_lf():
    return [float(f) for f in input().split()]


def get_lc():
    return list(input().strip())


def get_data(n, types):
    if len(types) == 1:
        return [types[0](input()) for _ in range(n)]
    return zip(*(
        [t(x) for t, x in zip(types, input().split())]
        for _ in range(n)
    ))


if __name__ == '__main__':
    main()

Solution (Python):
a,b,c,x,y=map(int,input().split())
if c*2<=a and c*2<=b:
  print(c*2*max(x,y))
  exit()
if c*2<=a:
  print(c*2*x+max(0,b*(y-x)))
  exit()
if c*2<=b:
  print(c*2*y+max(0,a*(x-y)))
  exit()
if c*2>=a+b:
  print(a*x+b*y)
  exit()
if x>=y:
  print(2*c*y+(x-y)*a)
else:
  print(2*c*x+(y-x)*b)

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

Solution (Python):
ans = 0
A, B, AB, X, Y = map(int, input().split())
AB = min(AB * 2, A + B)
m = min(X, Y)
ans += m * AB
X -= m
Y -= m
if X == 0:
    ans += min(B, AB) * Y
else:
    ans += min(A, AB) * X
print(ans)

Solution (Python):
a, b, c, x, y = [int(item) for item in input().split()]
c *= 2

gA_B = x * a + y * b
gAB = max(x,y) * c
if y > x:
  gAB_B = x * c + (y-x) * b
else:
  gAB_B = gAB
if x > y:
  gA_AB = (x-y) * a + y * c
else:
  gA_AB = gAB
  
print(min(gA_B, gAB, gA_AB, gAB_B))

Solution (Python):
A, B, C, X, Y = map(int, input().split())
minv = A*X + B*Y

tmp = C*X*2
if X > Y:
    minv = min(minv, tmp)
else:
    minv = min(minv, tmp+(Y-X)*B)

tmp = C*Y*2
if Y > X:
    minv = min(minv, tmp)
else:
    minv = min(minv, tmp+(X-Y)*A)
print(minv)

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

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

print(ans)

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