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: Wrong Answer

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

a_sum = a * x
b_sum = b * y
c_sum = c * (x+y)
price = 0

if a_sum + b_sum > c_sum:
    num = min(x, y)
    price += num * c * 2
    x -= num
    y -= num
    print(price)
    if x > 0:
        if a < c * 2:
            price += a * x
        else:
            price += c * 2 * x
    if y > 0:
        if b < c * 2:
            price += b * y
        else:
            price += c * 2 * y
else:
    price += a*x + b*y
print(price)

Submission status: Wrong Answer

Solution code:
f = lambda: map(int,input().split())

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

Submission status: Wrong Answer

Solution code:
a,b,c,x,y = list(map(int,input().split()))
dic = {a:x,b:y}
if 2*c >= a+b:print(a*x+b*y)
elif 2*c >= max(a,b):print(a*x+b*y-min(x,y)*(a+b-2*c))
elif 2*c >= min(a,b) and dic[min(a,b)]>=(x+y)/2:print(a*x+b*y-min(x,y)*(a+b-2*c))
else:print(dic[max(a,b)]*2*c)

Submission status: Wrong Answer

Solution code:
a,b,c,x,y = list(map(int,input().split()))
dic = {a:x,b:y}
if 2*c > a+b:print(a*x+b*y)
elif 2*c > max(a,b):print(a*x+b*y-min(x,y)*(a+b-2*c))
elif 2*b > min(a,b) and dic[min(a,b)]>=(x+y)/2:print(a*x+b*y-min(x,y)*(a+b-2*c))
else:print(dic[max(a,b)]*2*c)

Submission status: Wrong Answer

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

print(money)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
valuesStr = input()
[A, B, C, X, Y] = valuesStr.split(" ")
[A, B, C, X, Y] = [int(A), int(B), int(C), int(X), int(Y)]

price = 0

priceA = X * A + Y * B
if X > Y:
    priceB = (X - Y) * A + Y * 2 * C
    priceC = X * 2 * C
else:
    priceB = (Y - X) * A + X * 2 * C
    priceC = Y * 2 * C

print(min([priceA, priceB, priceC]))

Submission status: Wrong Answer

Solution code:
valuesStr = input()
[A, B, C, X, Y] = valuesStr.split(" ")
[A, B, C, X, Y] = [int(A), int(B), int(C), int(X), int(Y)]

price = 0

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

print(price)

Submission status: Wrong Answer

Solution code:
valuesStr = input()
[A, B, C, X, Y] = valuesStr.split(" ")
[A, B, C, X, Y] = [int(A), int(B), int(C), int(X), int(Y)]

price = 0

if A + B < 2 * C:
    print(1)
    price = X * A + Y * B
elif X > Y:
    print(2)
    price = (X - Y) * A + Y * 2 * C
else:
    print(3)
    price = (Y - X) * A + X * 2 * C

print(price)

Submission status: Wrong Answer

Solution code:
valuesStr = "1500 2000 1600 3 2"#input()
[A, B, C, X, Y] = valuesStr.split(" ")
[A, B, C, X, Y] = [int(A), int(B), int(C), int(X), int(Y)]

price = 0

if A + B < 2 * C:
    print(1)
    price = X * A + Y * B
elif X > Y:
    print(2)
    price = (X - Y) * A + Y * 2 * C
else:
    print(3)
    price = (Y - X) * A + X * 2 * C

print(price)

Submission status: Wrong Answer

Solution code:
valuesStr = input()
[A, B, C, X, Y] = valuesStr.split(" ")

print(A)

print

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

min_price = 10000000000000000000000000001

if min(A, B) >= 2*C :
    print(max(X, Y) * 2 * C)
else :
    for i in range(max(X, Y)) :
        cnt_a = max(0, X - i)
        cnt_b = max(0, Y - i)
        
        min_price = min(min_price, cnt_a * A + cnt_b * B + i * 2 * C)
        # print("DBG : ", cnt_a, cnt_b, i)
    print(min_price)

Submission status: Wrong Answer

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

min_price = 10000000000001

if min(A, B) >= 2*C :
    print(max(X, Y) * 2 * C)
else :
    for i in range(max(X, Y)) :
        cnt_a = max(0, X - i)
        cnt_b = max(0, Y - i)
        
        min_price = min(min_price, cnt_a * A + cnt_b * B + i * 2 * C)
        # print("DBG : ", cnt_a, cnt_b, i)
    print(min_price)

Submission status: Wrong Answer

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

min_price = 100001

if min(A, B) >= 2*C :
    print(max(X, Y) * 2 * C)
else :
    for i in range(max(X, Y)) :
        cnt_a = max(0, X - i)
        cnt_b = max(0, Y - i)
        
        min_price = min(min_price, cnt_a * A + cnt_b * B + i * 2 * C)
        # print("DBG : ", cnt_a, cnt_b, i)
    print(min_price)

Submission status: Wrong Answer

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

min_price = 100001

if min(A, B) >= 2*C :
    print(max(X, Y) * 2 * C)
else :
    for i in range(X + 1) :
        for j in range(Y + 1) :
            min_price = min(min_price, i * A + B * j + max(X - i, Y - j)*2*C)
            # print("min price @ ", i, j, max(X - i, Y - 1)*2, min_price)
    print(min_price)

Submission status: Wrong Answer

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

ans1 = a*x + b*y

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

print(min(ans1, ans2), ans3)

Submission status: Wrong Answer

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

ans1 = a*x + b*y

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

print(min(ans1, ans2))

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

Solution code:
a,b,c,X,Y=map(int,input().split())

nedan=X*a+Y*b
x=X
y=Y
z=0

if c*2<a and c*2<b:
   x=0
   y=0
   if X<=Y:
       z=2*Y
       print(x*a+y*b+z*c)
   else :
       z=2*X
       print(x*a+y*b+z*c)
else:
   if c*2<a or c*2<b:
       if a<=b:
           x=0
           y=Y-X
           z=X*2
           print(x*a+y*b+z*c)
       else :
           y=0
           x=X-Y
           z=Y*2
           print(x*a+y*b+z*c)


   else:
       while True:
           tmp=x*a+y*b+z*c
           if tmp>nedan or tmp<0 or x==0 or y==0:
               nedan=tmp
               break

           x=x-1
           y=y-1
           z=z+2

       print(nedan)

Submission status: Wrong Answer

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

min_value=100000*100000

if a>2*c:
    print(2*c*x+(y-2*c)*b)
elif b>2*c:
    print(2*c*y+(x-2*c)*a)
elif a+b>2*c:
    print(max(x,y)*2*c)
else:
    for C in range(0,max(x,y)*2,2):
        A=(x-C//2)
        B=(y-C//2)        

        value=A*a+B*b+C*c
        if 0<value<=min_value:
            min_value=value
        else:
            break
    print(min_value)

Submission status: Wrong Answer

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

min_value=100000*100000

if a+b>2*c:
    print(max(x,y)*2*c)
elif a>2*c:
    print(2*c*x+(y-2*c)*b)
elif b>2*c:
    print(2*c*y+(x-2*c)*a)
else:
    for C in range(0,max(x,y)*2,2):
        A=(x-C//2)
        B=(y-C//2)        

        value=A*a+B*b+C*c
        if 0<value<=min_value:
            min_value=value
        else:
            break
    print(min_value)

Submission status: Wrong Answer

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

min_value=100000*100000

if a+b>2*c:
    print(max(x,y)*2*c)
else:
    for C in range(0,max(x,y)*2,2):
        A=(x-C//2)
        B=(y-C//2)        

        value=A*a+B*b+C*c
        if 0<value<=min_value:
            min_value=value
        else:
            break
    print(min_value)

Submission status: Wrong Answer

Solution code:
import sys

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

if X >= Y:
    
    a = X * A + Y * B
    b = 2 * Y * C + (X - Y) * A
    c = 2 * X * C
    
    res = min([a,b,c])
    
if  X < Y:
    
    a = X * A + Y * B
    b = 2 * X * C + (Y - X) * A
    c = 2 * Y * C
    
    res = min([a,b,c])
print(res)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys

a,b,c, x,y = [int(x) for x in sys.stdin.readline().split(" ")]


if a + b < c * 2:
	z = a * x + b * y
else:
	d = abs(x - y)
	e = max(x, y) - d

	zd1 = (a if x > y else b) * d
	zd2 = c * e * 2

	z = c * e * 2 + min(zd1, zd2)

print(z)

Submission status: Wrong Answer

Solution code:
import sys

a,b,c, x,y = [int(x) for x in sys.stdin.readline().split(" ")]


if a + b < c * 2:
	z = a * x + b * y
else:
	d = abs(x - y)
	e = x - d

	zd1 = (a if x > y else b) * d
	zd2 = c * e * 2

	z = c * e * 2 + min(zd1, zd2)

print(z)

Submission status: Wrong Answer

Solution code:
import sys

a,b,c, x,y = [int(x) for x in sys.stdin.readline().split(" ")]


if a + b < c * 2:
	z = a * x + b * y
else:
	d = abs(x - y)
	e = x - d

	zd = (a if x > y else b) * d

	z = zd + c * e * 2

print(z)

Submission status: Wrong Answer

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


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

print(str(ans))

Submission status: Wrong Answer

Solution code:
#import numpy as np
#n = int(input())
ipt = [int(i) for i in input().split()]

a = ipt[0]
b = ipt[1]
c = ipt[2]
x = ipt[3]
y = ipt[4]

a_pizza = x
b_pizza = y
c_pizza = 0
if a+b > 2*c:
    c_pizza = 2*min(a_pizza, b_pizza)
    a_pizza -= c_pizza / 2
    b_pizza -= c_pizza / 2
if a_pizza > 0 and a > 2*c:
    c_pizza += a_pizza
    a_pizza = 0
if b_pizza > 0 and b > 2*c:
    c_pizza += b_pizza
    b_pizza = 0

print(int(a*a_pizza+b*b_pizza+c*c_pizza))

Submission status: Wrong Answer

Solution code:
#import numpy as np
#n = int(input())
ipt = [int(i) for i in input().split()]

a = ipt[0]
b = ipt[1]
c = ipt[2]
x = ipt[3]
y = ipt[4]

a_pizza = x
b_pizza = y
if a+b > 2*c:
    c_pizza = 2*min(a_pizza, b_pizza)
    a_pizza -= c_pizza / 2
    b_pizza -= c_pizza / 2
else:
    c_pizza = 0
print(int(a*a_pizza+b*b_pizza+c*c_pizza))

Submission status: Wrong Answer

Solution code:
input_str = input()

A, B, C, X, Y = input_str.split(" ")

A = int(A)
B = int(B)
C = int(C)
X = int(X)
Y = int(Y)

answer = 0
ave_AB = (A + B) / 2
if ave_AB <= C:
    answer = X*A + Y*B
    print(answer)
else:
    xy_min = min(X,Y)
    answer = xy_min * C * 2
    tmp = X - Y
    if tmp > 0:
        if A < C*2:
            answer += tmp*A
        else:
            answer += tmp*C*2
    elif tmp < 0:
        if B < C*2:
            answer += -tmp*B
        else:
            answer += -tmp*C*2
print(answer)

Submission status: Wrong Answer

Solution code:
input_str = input()

A, B, C, X, Y = input_str.split(" ")

A = int(A)
B = int(B)
C = int(C)
X = int(X)
Y = int(Y)

answer = 0
ave_AB = (A + B) / 3
if ave_AB <= C:
    answer = X*A + Y*B
    print(answer)
else:
    xy_min = min(X,Y)
    answer = xy_min * C * 2
    tmp = X - Y
    if tmp > 0:
        if A < C*2:
            answer += tmp*A
        else:
            answer += tmp*C*2
    elif tmp < 0:
        if B < C*2:
            answer += -tmp*B
        else:
            answer += -tmp*C*2
print(answer)

Submission status: Wrong Answer

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

pizza_num_dict = {'A': 0, 'B': 0}

price_sum = 0
if A >= 2 * C:
    pizza_num_dict['A'] += X
    pizza_num_dict['B'] += X
    price_sum += 2 * X * C
    if pizza_num_dict['B'] >= Y:
        print(price_sum)
        exit(0)
    else:
        if B >= 2 * C:
            price_sum += 2 * (Y - X) * C
        else:
            price_sum += (Y - X) * B
        print(price_sum)
        exit(0)

elif B >= 2 * C:
    pizza_num_dict['A'] += Y
    pizza_num_dict['B'] += Y
    price_sum += 2 * Y * C
    if pizza_num_dict['A'] >= X:
        print(price_sum)
        exit(0)
    else:
        price_sum == (X - Y) * A
        print(price_sum)
        exit(0)

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

Submission status: Wrong Answer

Solution code:
# input -- A B C X Y

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

# can buy '2 * Z' pieces of C-pizza 
Z = min(X, Y)
sum_of_pay = 0

if A+B > 2*C:
    sum_of_pay += 2 * Z * C

    if X-Z > 0: # if remain some A-pizza
        if A > 2*C:
            sum_of_pay += 2 * (X-Z) * C
        else: 
            sum_of_pay += (X-Z) * A
    else:      # B-pizza
        if B > 2*C:
            sum_of_pay += 2 * (Y-Z) * C
        else: 
            sum_of_pay += (Y-Z) * B
else: 
    sum_of_pay += (X*A + Y*B)

print(sum_of_pay)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
x = input().split()
A=int(x[0])
B=int(x[1])
C=int(x[2])
X=int(x[3])
Y=int(x[4])
D=(A+B)/2
if D>=C:
    if X>=Y:
        print(Y*C*2+(X-Y)*A)
    else:
        print(X*C*2+(Y-X)*B)
else:
    print(A*X+B*Y)

Submission status: Wrong Answer

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

C *= 2

res = 0

if X > Y:
    res += A*(X - Y)
    X = Y
elif X < Y:
    res += B*(Y - X)
    Y = X

if Y == 0:
    print(res)
    exit()

if A+B > C:
    res += C*X
else:
    res += A*X + B*Y

print(res)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if a+b >= 2*c:
    if x >= y:
        if a>=2*c:
            print(2*x*c)
        elif b>=2*c:
            print(y*2*c+(x-y-(y%2))*a)
        else:
            print((y//2)*4*c+(y%2)*b + (x-y)*a)
    else:
        if b>=2*c:
            print(2*y*c)
        elif a>=2*c:
            print(x*2*c+(y-x-(x%2))*a)
        else:
            print((x//2)*4*c+(x%2)*a + (y-x)*b)

else:
    print(x*a+y*b)

Submission status: Wrong Answer

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

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

else:
    print(x*a+y*b)

Submission status: Wrong Answer

Solution code:
import math, string, fractions, heapq, re, array, bisect, sys, random, time, copy
import itertools as it
import collections as cl
import functools as ft


def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


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


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

print(result)

Submission status: Wrong Answer

Solution code:
import math, string, fractions, heapq, re, array, bisect, sys, random, time, copy
import itertools as it
import collections as cl
import functools as ft


def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


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


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

print(result)

Submission status: Wrong Answer

Solution code:
import math, string, fractions, heapq, re, array, bisect, sys, random, time, copy
import itertools as it
import collections as cl
import functools as ft


def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


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


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

print(result)

Submission status: Wrong Answer

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

ans = A * X + B * Y
if X >= 2 and Y >= 2:

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

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

print(ans)

Submission status: Wrong Answer

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

ans = A * X + B * Y
if X >= 2 and Y >= 2:

    z = min(X // 2, Y // 2)
    ans = min(ans, A * (X - z * 2) + B * (Y - z * 2) + C * (z * 4))

    z = max(X // 2, Y // 2)
    ans = min(ans, A * max(0, (X - z * 2)) + B * max(0, (Y - z * 2)) + C * (z * 4))

print(ans)

Submission status: Wrong Answer

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

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

else:
    print(x*a+y*b)

Submission status: Wrong Answer

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

def money(A, B, C, X, Y):
    
    axby = A*X + B*Y
    if max([A, B, C]) == C:
        return axby
    
    cxy = C*max([X,Y])*2
    if X < Y:
        abcxy = C*X*2 + (Y-X)*B
    else:
        abcxy = C*Y*2 + (X-Y)*A
    
    print([axby, cxy, abcxy])
    return min([axby, cxy, abcxy])
  
print(money(A, B, C, X, Y))

Submission status: Wrong Answer

Solution code:
import sys

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

a = int(a)
b = int(b)
c = int(c)
x = int(x)
y = int(y)

# print(a)
# print(b)
# print(c)
# print(x)
# print(y)
#

best_price = sys.maxsize

for i in range(0, max(x + 1, y + 1) * 2 + 1, 2):
    rest_a = x
    rest_b = y

    if i // 2 >= x:
        rest_a = 0
    else:
        rest_a = x - i // 2

    if i // 2 >= y:
        rest_b = 0
    else:
        rest_b = y - i // 2

    price = rest_a * a + rest_b * b + c * i
    if price < best_price:
        best_price = price
    else:
        print(best_price)
        # break
    # print("buy a = " + str(rest_a) + ", b = " + str(rest_b) + ", c = " + str(i) + ", price = " + str(price))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys

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

a = int(a)
b = int(b)
c = int(c)
x = int(x)
y = int(y)

# print(a)
# print(b)
# print(c)
# print(x)
# print(y)
#

best_price = sys.maxsize

for i in range(0, max(x + 1, y + 1) * 2, 2):
    rest_a = x
    rest_b = y

    if i // 2 >= x:
        rest_a = 0
    else:
        rest_a = x - i // 2

    if i // 2 >= y:
        rest_b = 0
    else:
        rest_b = y - i // 2

    price = rest_a * a + rest_b * b + c * i
    if price < best_price:
        best_price = price
    else:
        print(best_price)
        break
    # print("buy a = " + str(rest_a) + ", b = " + str(rest_b) + ", c = " + str(i) + ", price = " + str(price))

Submission status: Wrong Answer

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

if X >= 2 and Y >= 2:
    if C * 2 < A + B:
        ans = 0
        z = min(X // 2, Y // 2)
        X -= (z * 2)
        Y -= (z * 2)
        ans += A * X + B * Y + C * (z * 4)
        print(ans)
        quit()
print(A * X + B * Y)

Submission status: Wrong Answer

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

avg = (a + b) // 2

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

print(cost)

Submission status: Wrong Answer

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

avg = (a + b) // 2

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

print(cost)

Submission status: Wrong Answer

Solution code:
l = map(int, raw_input().split())

if l[0] + l[1] < 2 * l[2]:
	if l[3] < l[4]:
		if (l[4] - l[3]) * l[1] < (l[4] - l[3]) * 2 * l[2]:
			print l[3] * 2 * l[2] + (l[4] - l[3]) * l[1]
		else:
			print l[4] * 2 * l[2]
	else:
		if (l[3] - l[4]) * l[0] < (l[3] - l[4]) * 2 * l[2]:
			print l[4] * 2 * l[2] + (l[3] - l[4])  * l[0]
		else:
			print l[3] * 2 * l[2]
else:
	print l[3] * l[0] + l[4] * l[1]

Submission status: Wrong Answer

Solution code:
A, B, C, X, Y = map(int, input().split())
cost = 0
if X > Y:
    max_index = A
    M = X
else:
    max_index = B
    M = Y

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

print(cost)

Submission status: Wrong Answer

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

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

min(a*x+b*y, l, max(x,y)*2*c)

Submission status: Wrong Answer

Solution code:
import math

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

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

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

Submission status: Wrong Answer

Solution code:
l = map(int, raw_input().split())

if l[0] + l[1] > 2 * l[2]:
	if l[3] < l[4]:
		print l[3] * 2 * l[2] + (l[4] - l[3]) * l[1]
	else:
		print l[4] * 2 * l[2] + (l[3] - l[4])  * l[0]
else:
	print l[3] * l[0] + l[4] * l[1]

Submission status: Wrong Answer

Solution code:
a,b,c,x,y = map(int, input().split())
def hoge(n):
    nx = max(0, x-n)
    ny = max(0, y-n)
    return 2*n*c + nx*a+ny*b

ans = 10**10

for i in range(10**5):
    ans = min(ans, hoge(i))

print(ans)

Submission status: Wrong Answer

Solution code:
l = map(int, raw_input().split())

if l[0] + l[1] < 2 * l[2]:
	if l[3] < l[4]:
		print l[3] * 2 * l[2] + (l[4] - l[3]) * l[1]
	else:
		print l[4] * 2 * l[2] + (l[3] - l[4])  * l[0]
else:
	print l[3] * l[0] + l[4] * l[1]

Submission status: Wrong Answer

Solution code:
a,b,c,x,y = map(int, input().split())
def hoge(n):
    nx = max(0, x-n)
    ny = max(0, y-n)
    return 2*n*c + nx*a+ny*b

ans = 10**10

for i in range(10**4):
    ans = min(ans, hoge(i))

print(ans)

Submission status: Time Limit Exceeded

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

min_sum = 9999999999
for a in range(X+1):
    for b in range(Y+1):
        c = max(X-a, Y-b)
        sum = A*a + B*b + 2*C*c
        if sum<min_sum:
            min_sum=sum
print(min_sum)

Submission status: Time Limit Exceeded

Solution code:
A,B,C,X,Y = map(int, input().split())
price = A*X + B*Y + 2*C*(X+Y)
for i in range(X+1):
  for j in range(Y+1):
    for k in range(2*max(X,Y)+2):
      while (i+2*k) >= X and (j+2*k) >= Y:
        num = A*i + B*j + C*k
        if num < price:
          price = num
print(price)

Submission status: Time Limit Exceeded

Solution code:
import sys
A, B, C, X, Y = map(int, sys.stdin.readline().split(" "))
ans = float("inf")
 
for i in range(X + 1):
    for j in range(Y + 1):
        k = max(X - i, Y - j) * 2
        ans = min(ans, A * i + B * j + C * k)
print(ans)

Submission status: Time Limit Exceeded

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

# 大きな値で初期化
TOTAL_MIN = A * X + B * Y + C * (X+Y) * 2

if 2 * C < A:
    i_max = 0
else:
    i_max = X
if 2 * C < B:
    j_max = 0
else:
    j_max = Y

for i in range(i_max + 1):
    for j in range(j_max + 1):
        k = max(X - i, Y - j) * 2
        total_tmp = A * i + B * j + C * k
        if total_tmp < TOTAL_MIN:
            TOTAL_MIN = total_tmp

print(TOTAL_MIN)

Submission status: Time Limit Exceeded

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

# 大きな値で初期化
TOTAL_MIN = A * X + B * Y + C * (X+Y) * 2
for i in range(X+1):
    for j in range(Y+1):
        k = max(X - i, Y - j) * 2
        total_tmp = A * i + B * j + C * k
        if total_tmp < TOTAL_MIN:
            TOTAL_MIN = total_tmp

print(TOTAL_MIN)

Submission status: Time Limit Exceeded

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

A + 2 // C > X
B + 2 // C > Y

# 大きな値で初期化
TOTAL_MIN = A * X + B * Y + C * (X+Y) * 2
for i in range(X+1):
    for j in range(Y+1):
        k = max(X - i, Y - j) * 2
        total_tmp = A * i + B * j + C * k
        if total_tmp < TOTAL_MIN:
            TOTAL_MIN = total_tmp

print(TOTAL_MIN)

Submission status: Time Limit Exceeded

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

min_cost = 1e10
for a in range(X+1):
    for b in range(Y+1):
        left = max(X-a, Y-b)
        cost = a*A + b*B + left*C*2
        if cost < min_cost:
            min_cost = cost
print(min_cost)

Submission status: Time Limit Exceeded

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

count_min = x * a + y * b
for p_a in range(x + 1):
    for p_b in range(y + 1):
        if x - p_a == y - p_b:
            p_ab = max((x - p_a), (y - p_b)) * 2
            count = p_a * a + p_b * b + p_ab * c
            if count < count_min:
                count_min = count

print(count_min)

Submission status: Time Limit Exceeded

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

count_min = x * a + y * b
for p_a in range(x + 1):
    for p_b in range(y + 1):
        for p_ab in range(max(x, y) * 2 + 1):
            if p_a + 0.5 * p_ab == x and p_b + 0.5 * p_ab == y:
                count = p_a * a + p_b * b + p_ab * c
                if count < count_min:
                    count_min = count

print(count_min)

Submission status: Time Limit Exceeded

Solution code:
a,b,c,x,y = map(int,input().split())
cost = a * x + b * y
for i in range(x):
        for j in range(y):
                k = 2 * max(x-i,y-j)
                cost_ = i * a + j * b + k * c
                if cost_ < cost:
                        cost = cost_
print(cost)

Submission status: Accepted

Solution code:
A,B,C,X,Y=map(int,input().split())
result=0
if A+B>=C*2:
  min_pizza=min(X,Y)
  min_pizza//2*2
  X-=min_pizza
  Y-=min_pizza
  result+=C*2*min_pizza
for i,j in zip((A,B),(X,Y)):
  if i>=C*2:
    result+=C*2*(max(0,j-2))
  else:
    result+=i*(max(0,j-2))
X-=max(0,X-2)
Y-=max(0,Y-2)
cnd=[C*2*2]
for i in range(3):
  for j in range(3):
    if X<=i and Y<=j:
      cnd.append(A*i+B*j)
result+=min(cnd)
print(result)

Submission status: Accepted

Solution code:
# author:  Taichicchi
# created: 25.09.2020 23:35:11

import sys

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

ans = 10 ** 18

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

print(ans)