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:
a,b,c,x,y=map(int,input().split())



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

Submission status: Accepted

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

Submission status: Accepted

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

# A and B
AandB = a*x + b*y
# AB and A or B
if x > y:
    ABandAorB = 2*c*y + a * (x-y)
else:
    ABandAorB = 2*c*x + b * (y-x)
# only AB
if x > y:
    AB = 2*c*x
else:
    AB = 2*c*y
print(min(AandB,ABandAorB,AB))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

cost1=a*x+b*y
cost2=c*2*max(x,y)
if min(x,y)==x:
    cost3=min(x,y)*2*c+(y-x)*b
else:
    cost3=min(x,y)*2*c + (x-y)*a
    
print(min(cost1,cost2, cost3))

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:
    price = min(x, y) * 2 * c
    n = abs(x - y)
    if x - min(x, y) > 0:
        if a*n <  2*c*n:
            price += a*n
        else:
            price += 2*c*n
    if y - min(x, y) > 0:
        if b*n <  2*c*n:
            price += b*n
        else:
            price += 2*c*n
    print(price)

Submission status: Accepted

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

Submission status: Accepted

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

d = min(a+b,2*c)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def solve(A, B, C, X, Y):
    ans = X * A + B * Y
    ans = min(ans, 2 * C * X + B * max(Y - X, 0))
    ans = min(ans, A * max(X - Y, 0) + 2 * C * Y)
    return ans

if __name__ == "__main__":
    A, B, C, X, Y = tuple(map(int, input().split(" ")))
    print(solve(A, B, C, X, Y))

Submission status: Accepted

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

Submission status: Accepted

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


main()

Submission status: Accepted

Solution code:
import math
a,b,c,x,y=map(int,input().split())
cost=float('inf')
if 2*c>=a+b:
    cost=a*x+b*y
else:
    least=min(x*2,y*2)
    most=max(x*2,y*2)
    r=least
    while r<=most:
        p=max(0,math.ceil(x-r/2))
        q=max(0,math.ceil(y-r/2))
        tmp=a*p+b*q+c*r
        cost=min(cost,tmp)
        r+=1
print(cost)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a, b, c, x, y = map(int, input().split())
c2 = c * 2
print(min([i * c2 + max(0, x - i) * a + max(0, y - i) * b for i in range(10**6)]))

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

ab1 = A + B
ab1c = C*2
ans = 0
if ab1 > ab1c:
    mi = min(X,Y)
    for i in range(mi):
        ans += C*2

    if X > Y:
        for i in range(X-Y):
            ans += A
    else:
        for i in range(Y-X):
            ans += B
else:
    for i in range(X):
        ans += A
    for i in range(Y):
        ans += B

t = 0
ma = max(X,Y)
for i in range(ma):
    t +=C*2

if t < ans:
    print(t)
    exit()

print(ans)

Submission status: Accepted

Solution code:
a,b,c,x,y = map(int,input().split())
res = 10**10
for i in range(0,2*max(x,y)+1,2):
    if x-i//2<0:
        na=0
    else:
        na=x-i//2
    if y-i//2<0:
        nb=0
    else:
        nb=y-i//2
    cost = a*na+b*nb+c*i
    if cost < res:
        res = cost
    else:
        break
print(res)

Submission status: Accepted

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

print(Ans)

Submission status: Accepted

Solution code:
A, B, C, X, Y = map(int,input().split())
value = 0
ans = []
ans.append(max(X,Y) * 2*C)
if X > 0 and Y > 0 and A + B > 2*C:
    m = min(X, Y)
    value += m * 2*C
    X = X - m
    Y = Y - m
value += (X * A + Y * B)
ans.append(value)
print(min(ans))

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
a,b,c,x,y = map(int,input().split())
m=[]
for i in range(10**5+1):
  m.append(2*c*i + a*max(0,x-i) + b*max(0,y-i))
print(min(m))

Submission status: Accepted

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

s = a * x + b * y
t = c * max(x, y) * 2
u = c * min(x, y) * 2 + a * (x - min(x, y)) + b * (y - min(x, y))

print(min(s, t, u))

Submission status: Accepted

Solution code:
a, b, ab, x, y = map(int, input().split())
average = (a + b) / 2

if average <= ab:
    ans = a * x + b * y
else:
    temp1 = ab * min(x, y) * 2 + a * (x - min(x, y)) + b * (y - min(x, y))
    temp2 = ab * max(x, y) * 2
    ans = min(temp1, temp2)
    
print(ans)

Submission status: Accepted

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

print(int(minS))

Submission status: Accepted

Solution code:
A,B,C,X,Y=(int(i) for i in input().split())
A = min(A,2*C)
B = min(B,2*C)
AB = min(A+B,2*C)
print(AB*min(X,Y)+A*(X-min(X,Y))+B*(Y-min(X,Y)))

Submission status: Accepted

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

Submission status: Accepted

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

def main():
    na = list(map(int, input().split()))
    A, B, C, X, Y = na[0], na[1], na[2], na[3], na[4]

    r = 0
    if A + B <= C * 2:
        r = A * X + B * Y
    elif C * 2 < A and C * 2 < B:
        r = C * 2 * max(X, Y)
    elif C * 2 < A:
        r = C * 2 * X
        if X < Y:
            r += B * (Y - X)
    elif C * 2 < B:
        r = C * 2 * Y
        if Y < X:
            r += A * (X - Y)
    else:
        r = C * 2 * min(X, Y)
        if X < Y:
            r += B * (Y - X)
        else:
            r += A * (X - Y)

    print(r)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

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

i = 0
ans = float('inf')
while i // 2 <= max(x, y):
    price = a * max(0, x - i // 2) + b * max(0, y - i // 2) + c * i
    ans = min(price, ans)
    i += 2

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
A,B,C,X,Y=map(int,input().split())
L=[]
L.append(A*X+B*Y)
for i in range(min(X,Y)+1):
    L.append(A*X+B*Y-A*i-B*i+2*C*i)
ans=min(L)
if max(X,Y)*2*C<ans:
    ans=max(X,Y)*2*C
print(ans)

Submission status: Accepted

Solution code:
A,B,C,X,Y=map(int,input().split())
L=[]
L.append(A*X+B*Y)
for i in range(min(X,Y)+1):
    L.append(A*X+B*Y-A*i-B*i+2*C*i)
ans=min(L)
if max(X,Y)*2*C<ans:
    ans=max(X,Y)*2*C
print(ans)

Submission status: Accepted

Solution code:
a, b, ab, x, y = map(int, input().split())
ave = (a + b) / 2

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

Submission status: Accepted

Solution code:
a, b, ab, x, y = map(int, input().split())
ave = (a + b) / 2
ans = 0

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
res = 10**30
a,b,c,x,y = map(int,input().split())
for i in range(0,max(x,y)+1):
    # ABを2*iまい買う
    tmp = 2 * i * c
    xx,yy = x - i, y - i
    tmp += max(0,xx) * a
    tmp += max(0,yy) * b
    res = min(res, tmp)
print(res)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a, b, ab, x, y = map(int, input().split())
ave = (a + b) / 2
minxy = min(x, y)
amt = 0

if ave > ab:
    amt += ab * minxy * 2
else:
    amt += (a + b) * minxy
    
if x == minxy:
    if b / 2 > ab:
        amt += ab * (y - minxy) * 2
    else:
        amt += b * (y - minxy)
else:
    if a / 2 > ab:
        amt += ab * (x - minxy) * 2
    else:
        amt += a * (x - minxy)
        
print(amt)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a, b, ab, x, y = map(int, input().split())
ave = (a + b) / 2
minxy = min(x, y)
ans = 0

if ave > ab:
    ans += 2 * minxy * ab
    if x > y:
        if a < ab * 2:
            ans += (x - minxy) * a
        else:
            ans += (x - minxy) * 2 * ab
    else:
        if b < ab * 2:
            ans += (y - minxy) * b
        else:
            ans += (y - minxy)  * 2 * ab
else:
    ans = a * x + b * y
    
print(ans)

Submission status: Accepted

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

if x > y:
    tmp1 = a
    tmp2 = x
    a = b
    b = tmp1
    x = y
    y = tmp2
    
arr = []

arr.append(a*x+b*y)
arr.append(b*y+(2*c-b)*x)
arr.append(2*c*y)

print(min(arr))

Submission status: Accepted

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

ans=A*X+B*Y
a=0

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

Submission status: Accepted

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

ans=A*X+B*Y
a=0

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

Submission status: Accepted

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

ans=1000000000000
for k in range(0,100000+1):
  i=x-k
  if i<0:
    i=0
  j=y-k
  if j<0:
    j=0
  price=a*i+b*j+2*c*k
  if price < ans:
    ans = price
    
print(ans)

Submission status: Accepted

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

z=max(x,y)

ans=1000000000000
for k in range(0,z+1):
  i=x-k
  if i<0:
    i=0
  j=y-k
  if j<0:
    j=0
  price=a*i+b*j+2*c*k
  if price < ans:
    ans = price
    
print(ans)

Submission status: Accepted

Solution code:
def main():
    a, b, c, x, y = map(int, input().split())
    res = a * x + b * y
    for n_c in range(2, 2 * max(x, y) + 1, 2):
        xx = x - n_c // 2
        yy = y - n_c // 2
        p = a * max(xx, 0) + b * max(yy, 0) + c * n_c
        res = min(res, p)
    print(res)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
pr_a, pr_b, pr_c, num_a, num_b = map(int, input().split())

res = 10**10
for num_half in range(max(num_a, num_b)+1):
    rest_a = (lambda x: x if x >= 0 else 0)(num_a - num_half)
    rest_b = (lambda x: x if x >= 0 else 0)(num_b - num_half)
    price = rest_a*pr_a + rest_b * pr_b + num_half * pr_c*2
    res = min(res, price)

print(res)

Submission status: Accepted

Solution code:
# coding:utf-8

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

for i in range(1000000):
    p = 2 * c * i
    if i < x:
        p += a * (x - int(i))
    if i < y:
        p += b * (y - int(i))
    
    price.append(p)

print(min(price))
    

"""
if (a>c):
    p += c*x*2
    flag = 1

else:
    p += a*x
    flag = 0

if (b>c) :
    if (flag==1):
        p+= (y-int(x/2)) * c
    else:
        p+= c*y*2
else:
    if (flag==1):
        p+= (y-int(x/2)) * c
    else:
        p+= b*y

print(p)

"""

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A,B,H,x,y = map(int,input().split(" "))
money = 0
if A + B <= H * 2:
    money += A * x
    money += B * y
else:
    if x >= y:
        money += (y * H) * 2
        if A <= H * 2:
            money += (x - y) * A
        else:
            money += (x - y) * (H * 2)
    else:
        money += (x * H) * 2
        if B <= H * 2:
            money += (y - x) * B
        else:
            money += (y - x) * (H * 2)
print(money)

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:
    if X>=Y:
        print(2*C*min(X,Y)+min(2*C*(X-Y),A*(X-Y)))
    else:
        print(2*C*min(X,Y)+min(2*C*(Y-X),B*(Y-X)))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# coding: utf-8
"""
purpose
"""


def main() -> None:
    """
    main function
    """
    (A, B, C, X, Y) = map(int, input().split())

    if 2 * C <= A + B:
        ans = C * min(X, Y) * 2 + min(max((X-Y)*A, (Y-X)*B), max(X-Y, Y-X)*C*2)
    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())

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

print(ans)

Submission status: Accepted

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

# 合計料金
total = 0

# import ipdb; ipdb.set_trace()

same_amount = min(x,y)

x -= same_amount
y -= same_amount

# AB2枚とA,Bを1枚ずつどちらがお得か
if a+b > 2*c:
    # AB2枚の方がお得の時
    total += 2*c*same_amount
else:
    # A,B1枚ずつの方がお得の時
    total += (a+b)*same_amount

# 残りも全てABを買ったほうが良いか確認
if (x*a + y*b) > (2*(x+y)*c):
    total += (2*(x+y)*c)
else:
    # 残ったピザを１枚ずつ買う
    total += (x*a + y*b)

print(total)

Submission status: Accepted

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

Submission status: Accepted

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

a1 = A * X + B * Y

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

ans = min(a1, a2)
print(ans)

Submission status: Accepted

Solution code:
# encoding: utf-8
A, B, C, X, Y = map(int, input().split())

candidate = [0] * 3

# all A or B
candidate[0] = A * X + B * Y

# either is replaced into AB
if X < Y: candidate[1] = (2 * C) * X + B * (Y - X)
else: candidate[1] = (2 * C) * Y + A * (X - Y)

# both is replaced into AB
candidate[2] = (2 * C) * max((X, Y))

print(min(candidate))

Submission status: Accepted

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

Submission status: Accepted

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

count = a * x + b * y

if x >= y:
	for i in range(x+1):
		if i > y:
			tmp = a * (x-i) + c * (i*2)
		else:
			tmp = a * (x-i) + b * (y-i) + c * (i*2)
		count = min(count, tmp)
else:
	for j in range(y+1):
		if j > x:
			tmp = b * (y-j) + c * (j*2)
		else:
			tmp = a * (x-j) + b * (y-j) + c * (j*2)
		count = min(count,tmp)

print(count)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
A, B, C, X, Y = [int(_) for _ in input().split()]
M = max(X, Y)
print(min(2 * C * M, 2 * C * (X + Y - M) + A *
          (M - Y) + B * (M - X), A * X + B * Y))

Submission status: Accepted

Solution code:
A, B, C, X, Y = [int(_) for _ in input().split()]
ans = A * X + B * Y
for i in range(max(X, Y) + 1):
    cost = 2 * C * i
    if X > i:
        cost += A * (X - i)
    if Y > i:
        cost += B * (Y - i)
    ans = min(ans, cost)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
iA,iB,iC,iX,iY = map(int,input().split())


if iY > iX:
    iX,iY = iY,iX
    iA,iB = iB,iA
print(min(2*iC*iX ,iX*iA+iY*iB, (iA+iB)*iY+2*iC*(iX-iY),2*iC*iY+iA*(iX-iY)))

Submission status: Accepted

Solution code:
import sys
input=sys.stdin.readline

a,b,c,x,y=map(int,input().split())
minxy=min(x,y)
deff=max(x,y)-minxy
if a+b<=2*c:
    print(a*x+b*y)
else:
    half=2*c*minxy
    if max(x,y)==x and a<=2*c:
        print(half+deff*a)
    elif max(x,y)==y and b<=2*c:
        print(half+deff*b)
    else:
        print(half+deff*2*c)

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:
    low = min(X,Y)
    high = max(X,Y)
    if C*(high-low)*2<=A*(X-low)+B*(Y-low):
        print(C*high*2)
    else:
        print(C*low*2+A*(X-low)+B*(Y-low))

Submission status: Accepted

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

cost = 0

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

diff = abs(X-Y)
if X > Y:
    if A > 2 * C:
        cost += 2 * C * diff
    else:
        cost += A * diff
else:
    if B > 2 * C:
        cost += 2 * C * diff
    else:
        cost += B * diff

print(cost)

Submission status: Accepted

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

miab = min(X, Y)
c1 = A * X + B * Y
c2 = C * miab * 2 + A * (X - miab) + B * (Y - miab)
c3 = C * max(X, Y) * 2

print(min(c1, c2, c3))

Submission status: Accepted

Solution code:
a,b,c,x,y=map(int,input().split())
AB_sum=min(a+b,c*2)#AB1枚ずつの最小値
ans=0
ans+=min(x,y)*AB_sum
if x<y:
    if b<c*2:
        ans+=b*(y-x)
    else:
        ans+=(c*2)*(y-x)
else:
    if a<c*2:
        ans+=a*(x-y)
    else:
        ans+=(c*2)*(x-y)
print(ans)

Submission status: Accepted

Solution code:
a,b,ab,x,y=map(int,input().split())
if(a<b):
    mymax=[b,y]
    mymin=[a,x]
else:
    mymax=[a,x]
    mymin=[b,y]


if( 2*ab <= mymin[0]):
    print( 2*ab*max([x,y]) )
elif(2*ab <=mymax[0]):
    if(max([x,y]) ==mymax[1]):
        nedan=ab*2*mymax[1]
    else:
        nedan=ab*2*min([x,y]) + (mymin[1]-mymax[1])*mymin[0]
    print(nedan)
elif(2*ab <=a+b):
    if(mymax[1]==max([x,y])):
        print(2*ab*mymin[1] + mymax[0]*(mymax[1]-mymin[1]))
    else:
        print(2*ab*mymax[1] + mymin[0]*(mymin[1] - mymax[1]) )
else:
    print(a*x+b*y)

Submission status: Accepted

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

p = A+B
q = 2*C
z = min(X,Y)
r = abs(X-Y)
if p <= q :
    ans = A*X+B*Y
else :
    ans = q*z
    if z == Y :
        if A <= 2*C :
            ans += A*r
        else :
            ans += q*r
    else :
        if B <= 2*C :
            ans += B*r
        else :
            ans += q*r
print(ans)

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 += y * c * 2
        x -= y
        y = 0
        if a >= c * 2:
            ans += x * c * 2
        else:
            ans += x * a
    else:
        ans += x * c * 2
        y -= x
        x = 0
        if b >= c * 2:
            ans += y * c * 2
        else:
            ans += y * b
else:
    ans += x * a + y * b

print(ans)

Submission status: Accepted

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

ans = 10**12
for c in range(max(X,Y) + 1):
    cost = C*2*c
    a = max(0, X-c)
    b = max(0, Y-c)
    cost += A*a + B*b
    ans = min(cost, ans)
print(ans)

Submission status: Accepted

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

ANS=10**12
for i in range(0,max(X,Y)*2+1,2):
    XRE=max(X-i//2,0)
    YRE=max(0,Y-i//2)

    if ANS>i*C+XRE*A+YRE*B:
        ANS=i*C+XRE*A+YRE*B

    #print(i,i*C+XRE*A+YRE*B)

print(ANS)

Submission status: Accepted

Solution code:
import sys
stdin = sys.stdin

sys.setrecursionlimit(10**5)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

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

abonly = a*x + b*y

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

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

print(min(abonly, abandc, conly))

Submission status: Accepted

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

Submission status: Accepted

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

z = min(x,y)
w = abs(x - y)
count = 0

if 2 * c > a + b:
    count += (a + b) * z
else:
    count += 2 * c * z

if x > y:
    if 2 * c < a:
        count += 2 * c * w
    else:
        count += a * w
elif x < y:
    if 2 * c < b:
        count += 2 * c * w
    else:
        count += b * w

print(count)

Submission status: Accepted

Solution code:
a,b,c,x,y = [int(i) for i in input().split()]
P = [0, x, y]
while P[1]>0 or P[2]>0:
  if P[1]>0 and P[2]>0 and a+b>c*2:
    P[0] += c*2
    P[1] -= 1
    P[2] -= 1
  elif P[1]>0 and P[2]>0 and c*2>a+b:
    P[0] += a+b
    P[1] -= 1
    P[2] -= 1
  elif P[1]>0 and a>c*2:
    P[0] += c*2
    P[1] -= 1
    P[2] -= 1
  elif P[2]>0 and b>c*2:
    P[0] += c*2
    P[1] -= 1
    P[2] -= 1
  elif P[1]>0:
    P[0] += a
    P[1] -= 1
  elif P[2]>0:
    P[0] += b
    P[2] -= 1
print(P[0])

Submission status: Accepted

Solution code:
def run(A, B, C, X, Y):
    '''
    以下のうち一番安い金額を出力する
    - A, Bピザ両方単独で買う
    - ABピザで少ない方全部まで買い、残りは単独で買う
    - ABピザで全部買う
    '''
    max_XY = max(X, Y)
    min_XY = min(X, Y)
    diff = max_XY - min_XY
    if X > Y:
        D = A
    else:
        D = B
    ret = A*X + B*Y
    ret = min(ret, min_XY*C*2 + diff*D)
    ret = min(ret, max_XY*C*2)
    return ret


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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

ans = 0
# A,B単体で買ったほうがよい場合
if 2 * C >= A + B:
    ans += A * X + B * Y

# Cを買ったほうが良い場合
else:
    if X > Y:
        ans = min((X - Y) * A + 2 * C * Y, 2 * C * X)
    else:
        ans = min((Y - X) * B + 2 * C * X, 2 * C * Y)

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(max(x, y)+1):
    temp = 2*c*i + max(x-i, 0)*a + max(y-i, 0)*b
    ans = min(ans, temp)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

ans1 = a*x + b*y
ans2 = ans1 + min(x, y)*(c*2 - a - b)
ans3 = max(x, y)*c*2

print(min(ans1, ans2, ans3))