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 = map(int,input().split())

mid = min(x,y)
rest = max(x,y)-mid
if x>y: a_b = a
else: a_b = b

total = 0

if 2*c <  a+b:
    total += mid*2 *c
else:
    total += mid   *(a+b)
    

if 2*c < a_b:
    total += rest*2 *c
else:
    total += rest   *a_b

print(total)

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

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

Solution (Python):
A,B,C,X,Y=map(int,input().split())
ans_2=A*X+B*Y
ans=min(X,Y)*2*C
mindelta_X=A*(max(X,Y)-min(X,Y))
mindelta_Y=B*(max(X,Y)-min(X,Y))


for i in range(1,max(X,Y)+1-min(X,Y)):
    delta=0
    if X>Y:
        delta=2*C*i+A*(max(X,Y)-min(X,Y)-i)
        if delta<mindelta_X:
            mindelta_X=delta
    if Y>X:
        delta=2*C*i+B*(max(X,Y)-min(X,Y)-i)
        if delta<mindelta_Y:
            mindelta_Y=delta

print(min([ans+mindelta_X,ans_2]) if X>Y else min([ans+mindelta_Y,ans_2]))

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

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

min_value = X if (X < Y) else Y

total = 0
if (A + B > C * 2):
  total = C * 2 * min_value
else:
  total = (A + B) * min_value

current_X = X - min_value
current_Y = Y - min_value
if(current_X != 0):
  if(A > C * 2):
    total += current_X * C * 2
  else:
    total += current_X * A
else:
  if(B > C * 2):
    total += current_Y * C * 2
  else:
    total += current_Y * B
print(total)

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

C = max(x, y) * 2 * c
print(min(A, B, C))

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

ans = 10 ** 18

for k in range(10 ** 5 + 10):
    ans = min(ans, 2 * C * k + max(0, X - k) * A + max(0, Y - k) * B)

print(ans)

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

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

h = a*x+b*y
i = a*(x-min([x,y]))+b*(y-min([x,y]))+2*c*min([x,y])
j = 2*c*max([x, y])
print(min([h, i, j]))

Solution (Python):
a, b, c, x, y = map(int, input().split())
ans = float('inf')
for i in range(100001):
    ans = min(ans, c * 2 * i + max(x - i, 0) * a + max(y - i, 0) * b)
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 += (x - y) * min(a, c * 2)
elif y > x:
    ans += (y - x) * min(b, c * 2)
print(ans)

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

a, b, c, x, y = map(int, input().split())
ab = 2 * c
m = 10 ** 9
for i in range(0, max(x, y) + 1):
    p = ab * i + a * max(0, x - i) + b * max(0, y - i)
    if m > p:
        m = p
print(m)

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

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

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

maxV = max(X, Y)
min_prise = pow(10, 10)


for AB_cnt in range(maxV * 2 + 1):
  
  if X - AB_cnt // 2 > 0:
    A_prise = (X - AB_cnt // 2) * A
  else:
    A_prise = 0

  
  if Y - AB_cnt // 2 > 0:
    B_prise = (Y - AB_cnt // 2) * B
  else:
    B_prise = 0

  
  AB_prise = AB_cnt * C

  
  sum_prise = A_prise + B_prise + AB_prise

  
  if sum_prise < min_prise:
    min_prise = sum_prise

print(min_prise)

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

cost = float("inf")
for i in range(100001):
    tc = c * i * 2 + max(a * (x - i), 0) + max(b * (y - i), 0)

    cost = min(cost, tc)

print(cost)

Solution (Python):
def main():
    a, b, ab, x, y = map(int, input().split())
    
    ab *= 2
    ab_x = ab * x + b * max((y - x), 0)
    ab_y = ab * y + a * max((x - y), 0)
    ab_0 = a * x + b * y
    print(min(ab_x, ab_y, ab_0))


if __name__ == "__main__":
    main()

Solution (Python):



import sys
input = sys.stdin.readline
MOD = 10**9 + 7
INF = float('INF')

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

    cm = 2 * max(x, y)
    ans = INF

    for cbuy in range(cm+1):
        xbuy = max(0, x - (cbuy//2))
        ybuy = max(0, y - (cbuy//2))
        price = xbuy * a + ybuy * b + cbuy * c
        ans = min(ans, price)

    print(ans)

if __name__ == '__main__':
    main()

Solution (Python):
A,B,C,X,Y=map(int,input().split())
l=[[A,X],[B,Y]]
l.sort(key=lambda x:x[1], reverse=True)

if (A+B)>2*C:
    l[0][1]=l[0][1]-min(X,Y)
    l[1][1]=l[1][1]-min(X,Y)
    if l[0][1]*l[0][0]<C*2*l[0][1]:
        print(2*C*min(X,Y)+l[0][1]*l[0][0])
    else:
        print(2*C*max(X,Y))
else:
    print(A*X+B*Y)

Solution (Python):


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

cost = int(1e10)
for num_ac in range(0, int(1e5) + 1):
    num_A = max(0, X - num_ac)
    num_B = max(0, Y - num_ac)
    c = 2 * C * num_ac + A * num_A + B * num_B
    cost = min(c, cost)
print(cost)

Solution (Python):
A,B,AB,X,Y= list(map(int, input().split()))
ans = (X * A) + (Y * B)
max_ab_cnt = max(X,Y)
for ab_cnt in range(max_ab_cnt+1):
    a_cnt = max(X - ab_cnt, 0)
    b_cnt = max(Y - ab_cnt,0)
    tmp = (a_cnt *A) + (ab_cnt * 2 * AB) + (b_cnt * B)
    ans = min(ans, tmp)
print(ans)

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

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

ans = float("inf")
for k in range(0, max(x, y)*2+1, 2):
    i = 0 if x-k//2 < 0 else x-k//2
    j = 0 if y-k//2 < 0 else y-k//2
    ans = min(ans, a*i+b*j+c*k)

print(ans)

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

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

print(ans)

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

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

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


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

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

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

print(ans)

Solution (Python):
import sys

def solve():
    A, B, C, X, Y = map(int, input().split())
    C *= 2
    if X > Y:
        X, Y = Y, X
        A, B = B, A
    
    minCost = A * X + B * Y
    allC = Y * C
    XCYB = X * C + (Y - X) * B
    print(min(minCost, min(allC, XCYB)))
   
    return 0

if __name__ == "__main__":
    solve()

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

Solution (Python):
A, B, C, X, Y = [int(x) for x in input().split()]
ans = 0

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

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

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

print(ans)

Solution (Python):
A, B, C, X, Y = map(int, input().split())
pair = min(A + B, 2 * C) 
ans = 0
remained_X = X!=0
remained_Y = Y!=0

while X != 0 and Y != 0:
    ans += pair
    X -= 1
    Y -= 1

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

print(ans)

Solution (Python):
import math
import copy
from operator import mul
from functools import reduce
from collections import defaultdict
from collections import Counter
from collections import deque

from itertools import product

from itertools import permutations

from itertools import combinations
from bisect import bisect_left, bisect_right


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]

def i_inpl(): return int(input())
def l_inpl(): return list(map(int, input().split()))
INF = float("inf")





def main():
    a, b, c, x, y = l_inpl()
    ans = INF
    for i in range(max(x, y)*2+2):
        j = max(0, x-i//2)
        k = max(0, y-i//2)
        ans = min(ans, i*c+j*a+k*b)
    print(ans)
if __name__ == "__main__":
    main()

Solution (Python):


import math
def solve():
  a,b,c,x,y = (int(i) for i in input().split())
  ans = 10**15
  for ab in range(max(x,y)+15):
    cost = 0
    buyab = ab*2
    cost += buyab*c
    cost += a*max(x-ab,0) + b*max(y-ab,0)
    
    ans = min(cost,ans)
  print(ans)
solve()

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

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

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

if (a+b) > c*2:
  tmp = min(x,y)
  if x > y:
    print(min(c*2*tmp + a*(x-y), c*2*x))
  else:
    print(min(c*2*tmp + b*(y-x), c*2*y))
else:
  print(a*x + b* y)

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

res = float('inf')
for i in range(max(2*X,2*Y)+1):
    tmp = 2*i*C + max(0,X-i)*A + max(0,Y-i)*B
    res = min(res, tmp)
print(res)

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

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

res = float('inf')
for c in range(10**5+1):
    a = X-c
    b = Y-c
    cost = C*c*2
    cost += max(a,0)*A
    cost += max(b,0)*B
    res = min(res, cost)
print(res)

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

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

ans=10**10

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

Solution (Python):


import sys
import math
import time

import collections
from collections import deque
import queue
import copy






ABCXY = str(input()).split()
A = int(ABCXY[0])
B = int(ABCXY[1])
C = int(ABCXY[2])
X = int(ABCXY[3])
Y = int(ABCXY[4])
ans1 = 0
ans2 = 0
ans3 = 0

XY = X

ans3=C*2*Y + A*(X-Y)

if(X<Y):
  XY = Y
  ans3 = C*2*X + B*(Y-X)


ans1 = A*X+B*Y
ans2 = C*2*XY

ans = min(ans1,ans2)
ans = min(ans,ans3)


print(ans)

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

prices = []
if X > Y:
    half_max_count = X + 1
else:
    half_max_count = Y + 1



for i in range(0, half_max_count):
    a_price = int(X - i) * A if (int(X - i) >= 0) else 0
    b_price = int(Y - i) * B if (int(Y - i) >= 0) else 0
    half_price = 2 * i * C
    price = half_price + a_price + b_price
    prices.append(price)
print(min(prices))

Solution (Python):

INF = int(1e9)
def main():
    a, b, c, x, y = map(int, input().split())
    ans = INF
    for k in range(10**5+10):
        tmp = 2*c*k + max(x-k, 0)*a + max(y-k, 0)*b
        ans = min(ans, tmp)
    print(ans)
main()

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

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

cnt_A = max(X, Y)
cnt_B = max(X, Y)

ans = 10**9 + 1

for i in range(int(1e5 + 1)):
    acc = i * 2 * C + max(0, X - i) * A + max(0, Y - i) * B
    ans = min(ans, acc)

print(ans)

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


    
if __name__ == '__main__':
    main()

Solution (Python):


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

s = []
for i in range(0, 10 ** 5 + 1):
    s.append(i * c * 2 + max(x - i, 0) * a + max(y - i, 0) * b)

print(min(s))

Solution (Python):


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

p = max(x, y) * c * 2
m = min(x, y)
q = m * c * 2 + (x - m) * a + (y - m) * b
r = a * x + b * y

print(min(p, q, r))

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

plan_a = c * (2*x) + max(0, y-x) * b
plan_b = c * (2*y) + max(0, x-y) * a
plan_c = a * x + b * y

print(min(plan_a, plan_b, plan_c))

Solution (Python):

def main():

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


    
if __name__ == '__main__':
    main()

Solution (Python):

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

price = float("inf")
for i in range(10**7):
    price = min(price,i*2*c + max(0,x-i)*a +  max(0,y-i)*b)

print(price)

Solution (Python):

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

price = 10**16
for i in range(10**7):
    price = min(price,i*2*c + max(0,x-i)*a +  max(0,y-i)*b)

print(price)

Solution (Python):
A,B,C,X,Y=map(int,input().split())
ans=float('inf')
for ab in range(0,200001,2):
    ans=min(ans, ab*C+A*max(0,X-ab//2)+B*max(0,Y-ab//2))
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:
        ans=2*c*y
        rem=x-y
        ans+=min(2*rem*c,rem*a)
    elif x<y:
        ans=2*c*x
        rem=y-x
        ans+=min(2*rem*c,rem*b)
    else:ans=2*c*x
    print(ans)

Solution (Python):


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

common = 0

ans = 0

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

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

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

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

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

half = 0
if C * 2 <= A:
    half = X * 2
if C * 2 <= B:
    half = max(Y * 2, half)
if C <= (A + B) // 2:
    half = max(half, min(X, Y) * 2)

cost = half * C
X -= half // 2
Y -= half // 2

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

print(cost)

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

mod = 10**9 + 7

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))

A, B, C, X, Y = na()
ans = 10**10
for ab in range((10**5+1)*2):
    cost = ab * C
    cost += max(0, X - ab//2) * A
    cost += max(0, Y - ab//2) * B
    ans = min(ans, cost)
print(ans)

Solution (Python):
a,b,c,x,y = map(int,input().split())
res = 9999999999999
for i in range(0, 200002, 2):
    na = x - i//2
    nb = y - i//2
    na = 0 if na < 0 else na
    nb = 0 if nb < 0 else nb
    res = min(res, c * i + a*na + b*nb)
print(res)

Solution (Python):

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

if a + b < c * 2:
    p = a * x + b * y
else:
    if x > y:
        x -= y
        z = y * 2
        y = 0
        if a > c * 2:
            z += x * 2
            x = 0

    else:
        y -= x
        z = x * 2
        x = 0
        if b > c * 2:
            z += y * 2
            y = 0

print(x * a + y * b + z * c)

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

if (2*c<a and 2*c<b):
    
    ans = max(x,y)*2*c

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

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

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

Solution (Python):
import sys, math
def input():
    return sys.stdin.readline()[:-1]
from itertools import permutations, combinations
from collections import defaultdict, Counter
from math import factorial
from bisect import bisect_left 


sys.setrecursionlimit(10**7)
A, B, C, X, Y = map(int, input().split())

val1 = A*X + B*Y
minXY = min(X, Y)
val2 = C*2*minXY + A*(X-minXY) + B*(Y-minXY)
maxXY = max(X, Y)
val3 = C*2*maxXY

print(min(val1, val2, val3))

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

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




ans = A*X + B*Y



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


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


print(ans)

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

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

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

print(ans)

Solution (Python):
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 

def ii(): return int(sys.stdin.readline().rstrip()) 
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) 
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]

def ss(): return sys.stdin.readline().rstrip() 
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) 
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]





a,b,c,x,y=mii()

ans=10**100

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


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(a*(x-y)+2*c*y)
        else:
            print(2*c*x)
    else:
        if b<2*c:
            print(b*(y-x)+2*c*x)
        else:
            print(2*c*y)

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

Solution (Python):
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time


def I(): return int(input())


def S(): return input()


def MI(): return map(int, input().split())


def MS(): return map(str, input().split())


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


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YNL = {False: 'No', True: 'Yes'}
YNU = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']

show_flg = False



def main():
    A, B, C, X, Y = MI()

    a = A * X + B * Y
    b = max(C * X * 2, C * Y * 2)
    c = C * X * 2 + B * max(Y - X, 0)
    d = C * Y * 2 + A * max(X - Y, 0)
    print(min(a, b, c, d))


if __name__ == '__main__':
    main()

Solution (Python):
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 

def ii(): return int(sys.stdin.readline().rstrip()) 
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) 
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]

def ss(): return sys.stdin.readline().rstrip() 
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) 
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]





a,b,c,x0,y0=mii()

tmp=10**100

x,y=x0,y0
chk=min(x//2,y//2)
ans = c*2 *(chk)*2
x-=chk*2
y-=chk*2 
if x>=1:
    ans+=min(a*x,x*c*2)
if y>=1:
    ans+=min(y*b,y*c*2)
tmp=min(ans,tmp)

x,y=x0,y0
chk=max(x//2,y//2)
ans = c*2 *(chk)*2
x-=chk*2
y-=chk*2 
if x>=1:
    ans+=min(a*x,x*c*2)
if y>=1:
    ans+=min(y*b,y*c*2)
tmp=min(ans,tmp)

x,y=x0,y0
ans =a*x+b*y
tmp=min(ans,tmp)

ans=a*x + c*2*y
tmp=min(ans,tmp)

ans=c*2*x+b*y
tmp=min(ans,tmp)

if x>=y:
    ans=a*(x-y) + c*2*y
    tmp=min(ans,tmp)   

if x<=y:
    ans=c*2*x+b*(y-x)
    tmp=min(ans,tmp)


print(tmp)

Solution (Python):
import sys

A, B, C, X, Y = map(int, sys.stdin.readline().split(" "))

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

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

print(ans)

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

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

Solution (Python):
A,B,C,X,Y = map(int,input().split())
if A+B <= 2*C:
    ans = A*X + B*Y
else:
    ans = min(X,Y) * 2 * C
    if X > Y:
        ans += (X-Y) * min(A,2*C)
    elif X < Y:
        ans += (Y-X) * min(B,2*C)
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*min(X,Y)+A*max(0,X-Y)+B*max(0,Y-X)))

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

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

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

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

Solution (Python):
def ABC106_B():
    def make_divisors(n):
        divisors = []
        for i in range(1, int(n ** 0.5) + 1):
            if n % i == 0:
                divisors.append(i)
                if i != n // i:
                    divisors.append(n // i)
        
        return divisors
    N = I()
    ans = 0
    for i in range((N+1)//2):
        cur = i*2+1
        if len(make_divisors(cur))==8:
            ans += 1
    print(ans)
    return

def ABC122_B():
    S = SI()
    ans = 0
    cur = 0
    d = {"A","C","G","T"}
    for s in S:
        if s in d:
            cur += 1
        else:
            ans = max(ans,cur)
            cur = 0
    ans = max(ans,cur)
    print(ans)
    return

def paken2019_C():
    N, M = LI()
    A = [LI()for _ in range(N)]
    T = [i for i in range(M)]
    ans = 0
    for t1,t2 in itertools.permutations(T,2):
        cur = 0
        for i in range(N):
            cur += max(A[i][t1],A[i][t2])
        ans = max(ans,cur)
    print(ans)
    return

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

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

import sys,copy,bisect,itertools,heapq,math,random
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

if __name__ == '__main__':
    ABC95_C()

"""

"""

Solution (Python):
a, b, c, x, y = map(int, input().split())
mi = 10**10
for i in range(10**6):
    cost = c*2*i + a*max((x-i), 0) + b*max((y-i), 0)
    if cost < mi:
        mi = cost

print(mi)

Solution (Python):
A,B,C,x,y = map(int,input().split())
a = 0
b = 0
c = 0
if C*2 >= A + B:
    print (A*x+B*y)
    exit(0)

if C * 2 <= A and C * 2 <= B:
    print (max(x,y) * 2 * C)
    exit(0)

if x > y:
    if A >= C * 2:
        c = x * 2
    else:
        c = y * 2
        a = (x-y)
else:
    if B >= C * 2:
        c = y * 2
    else:
        c = x * 2
        b = (y-x)
print(A*a + B*b + C*c)

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

M=max(X,Y)*2
ans=float('inf')
for i in range(M+1):
  x=max(0,X-i//2)
  y=max(0,Y-i//2)
  
  
  tmp=A*x+B*y+C*i
  if ans>tmp:
    ans=tmp
print(ans)

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

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

print(answer)

Solution (Python):
import sys
import math
from collections import deque
import copy
import bisect

MOD = 10 ** 9 + 7
INF = 10 ** 18 + 7
input = lambda: sys.stdin.readline().strip()

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

ans = 0
while X > 0 or Y > 0:
    if X > 0 and Y > 0:
        if 2*C <=  A+B:
            X -= 1
            Y -= 1
            ans += 2*C
        else:
            X -= 1
            Y -= 1
            ans += A+B
    elif X > 0:
        if 2*C <= A:
            X -= 1
            ans += 2*C
        else:
            X-= 1
            ans += A
    else:
        if 2*C <= B:
            Y -= 1
            ans += 2*C
        else:
            Y -= 1
            ans += B
print(ans)

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

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

ans = 5000*(10**5)*2
for i in range(max(x, y)+1):
    tmp_ans = i*2*c
    if x > i:
        tmp_ans += (x-i)*a
    if y > i:
        tmp_ans += (y-i)*b
    ans = min(ans, tmp_ans)

print(ans)