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:
l = map(int, raw_input().split())
a = l[0]
b = l[1]
c = l[2]
x = l[3]
y = l[4]

if a+b <= 2*c:
	price = a*x + b*y
	tmp = 0
else:
	if x < y:
		price = 2*c*x
		tmp = y-x
	else:
		price = 2*c*y
		tmp = x-y

if tmp !=0:
	if x > y:
		if tmp*a > tmp*2*c:
			price += tmp*2*c
		else:
			price += tmp*a
	elif y > x:
		if tmp*b > tmp*2*c:
			price += tmp*2*c
		else:
			price += tmp*b

print price

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b,c,x,y = map(int, input().split())
only = a * x + b * y 
ans = only
for i in range(1,x + 1):
    current = 0
    current = c * i * 2
    if y - i >= 0:
        current = current + a * ( x - i ) + b * (y - i)
    else:
        current = current + a * ( x - i )
    if ans > current:
        ans = current
for i in range(1,y + 1):
    current = 0
    current = c * i * 2
    if x - i >= 0:
        current = current + a * ( x - i ) + b * ( y - i )
    else:
        current = current + b * ( y - i )
    if ans > current:
        ans = current
print(ans)

Submission status: Accepted

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

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



value = 0

na = 0
nb = 0
nc = 0


if A+B <= 2*C:
  value = X * A + Y * B
else:
  if X > Y:
    if 2*C <= A:
      nc = 2*X
    else:
      na = X - Y
      nc = 2*Y
  else:
    if 2*C <= B:
      nc = 2*Y
    else:
      nb = Y - X
      nc = 2*X
  value = A * na + B * nb + C * nc

print(value)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

set_ga_otoku = c * 2 < a + b
nimai_ga_otoku_a = c * 2 < a
nimai_ga_otoku_b = c * 2 < b

dup = min(x, y)
cost = c * 2 * dup if set_ga_otoku else a * dup + b * dup

x, y = map(lambda x: x - dup, [x, y])

if x:
    cost += c * 2 * x if nimai_ga_otoku_a else a * x
else:
    cost += c * 2 * y if nimai_ga_otoku_b else b * y

print(cost)

Submission status: Accepted

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

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

Submission status: Accepted

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

ans = 0

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

print(ans)

Submission status: Accepted

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

else:
    yen += A*X + B*Y

print(yen)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():

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

    num_a = 0
    num_b = 0
    num_c = 0

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

    left_X = max(X-num_c/2, 0)
    left_Y = max(Y-num_c/2, 0)

    # print(num_c, left_X, left_Y)
    if A + B >= C*2:
        num_c += min(left_X, left_Y)*2

    num_a = max(X-num_c/2, 0)
    num_b = max(Y-num_c/2, 0)

    # print(num_a, num_b, num_c)

    print(int(A*num_a + B*num_b + C*num_c))


if __name__ == '__main__':
    main()

Submission status: Accepted

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

tmp = min(X, Y)
if tmp * A + tmp * B < tmp * C * 2:
    a += tmp
    b += tmp
else:
    c += tmp * 2
X -= tmp
Y -= tmp
if X:
    if C * 2 < A:
        c += X * 2
    else:
        a += X
if Y:
    if C * 2 < B:
        c += Y * 2
    else:
        b += Y
print(a * A + b * B + c * C)

Submission status: Accepted

Solution code:
import builtins
import functools
import sys
import textwrap
from io import StringIO


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

    cost_min = sys.maxsize
    for c in range(max([X, Y]) + 1):
        cost = c * 2 * C
        a = X - c
        b = Y - c
        if a > 0:
            cost += a * A
        if b > 0:
            cost += b * B
        cost_min = min([cost_min, cost])
    print(cost_min)


if __name__ == '__main__':
    solve(builtins.input, functools.partial(builtins.print, flush=True))


def make_input(s):
    ss = textwrap.dedent(s).splitlines()
    it = iter(ss)
    return functools.partial(next, it)


def execute_solve(input_text):
    result = StringIO()
    solve(make_input(input_text),
          functools.partial(print, file=result, flush=True))
    return result.getvalue()


def test_solve():
    assert execute_solve('1500 2000 1600 3 2') == '7900\n'
    assert execute_solve('1500 2000 1900 3 2') == '8500\n'
    assert execute_solve('1500 2000 500 90000 100000') == '100000000\n'

Submission status: Accepted

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

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

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

Submission status: Accepted

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

if X<Y:
        t = X
        X = Y
        Y = t
        t = A
        A = B
        B = t

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b,c,x,y = map(int,input().split())
if a + b >= 2*c:
	if x >= y:
		ans = 2*y*c + (x-y)*min(a,2*c)
	else:
		ans = 2*x*c + (y-x)*min(b,2*c)
else:
	ans = (x*a + y*b)
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):
	money = max(0,(x-i)*a) + max(0,(y-i)*b) + 2*i*c
	if money <= ans:
		ans = money
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/python3

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

min = float('inf')
for i in range(max(x, y) + 1):
    pa = (x - i) * a
    if pa < 0:
        pa = 0
    pb = (y - i) * b
    if pb < 0:
        pb = 0
    pc = c * 2 * i
    sum = pa + pb + pc
    if min > sum:
        min = sum

print(min)

Submission status: Accepted

Solution code:
A, B, C, X, Y = [int(i) for i in input().split()]
price = 0
if A + B <= C*2:
    price += A*X+B*Y
else:
    price += C*2*min(X, Y)
    if A <= C*2 and X > Y:
        price += A*(X-Y)
    elif B <= C*2 and X < Y:
        price += B*(Y-X)
    else:
        price += C*2*abs(X-Y)
print(price)

Submission status: Accepted

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

    if m == X:
        if B > 2 * C:
            result += 2 * max(X, Y) * C
        else:
            result += 2 * m * C + (Y - m) * B
    else:
        if A > 2 * C:
            result += 2 * max(X, Y) * C
        else:
            result += 2 * m * C + (X - m) * A

print(result)

Submission status: Accepted

Solution code:
A,B,C,X,Y = map(int, raw_input().split())
  
m = min(X,Y)
M = max(X,Y)
result = 0
if A + B >= 2 * C:
    result += C * m * 2
    if m == X:
        result += (Y - X) * min(B, 2*C)
    else:
        result += (X - Y) * min(A, 2*C)
else:
    result =  A * X + B * Y

print(result)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

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

ans = 9999999999
for z in range(0, 1000001, 2):
    result = A * max(0, int(X - (z / 2))) + B * max(0, int(Y - (z / 2))) + C * z
    ans = min(ans, result)
print(ans)

Submission status: Accepted

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

ans = float('inf')
for nc in range(0, max(x, y) * 2 + 1, 2):
    na = x - math.floor(nc / 2)
    if na < 0:
        na = 0
    nb = y - math.floor(nc / 2)
    if nb < 0:
        nb = 0
    total = a * na + b * nb + c * nc
    if total < ans:
        ans = total
    # print(na, nb, nc, total)
print(ans)

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

Submission status: Accepted

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

if x < y:
    pizza = [(x, a), (y, b)]
else:
    pizza = [(y, b), (x, a)]

values = list()
values.append(c * 2 * pizza[0][0] + pizza[1][1] * (pizza[1][0] - pizza[0][0]))
values.append(c * 2 * pizza[1][0])
values.append(a * x + b * y)

print(min(values))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#Half and Half

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

#計算
Yen = []
for i in range(max(X+1,Y+1)):
	Yen.append(A*max(0,X-i) + B*max(0,Y-i) + 2*C*i)

#出力
print(min(Yen))

Submission status: Accepted

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

money = 0
if a + b > c * 2 :

	c_num = y * 2 if x > y else x * 2 #x > y ? y*2 : x*2
	money += c * c_num

	rest_money = a if x > y else b #x > y ? a : b
	rest_num = x-y if x > y else y-x #x > y ? x-y : y-x
	
	money += c * 2 * rest_num if rest_money > c*2 else rest_money * rest_num

else :
	money += a * x + b * y

print money

Submission status: Accepted

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

pay = []

for i in range(max(X,Y)+1):
    pay.append(i*2*C + max(0,X-i)*A + max(0,Y-i)*B)
    
print(min(pay))

Submission status: Accepted

Solution code:

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

if A < B:
    A, B = B, A
    X, Y = Y, X    
    
if A > C*2 and B > C*2:
    print(C*2*max(X,Y))

elif A > C*2 and B < C*2:
    print(2*C*X + B*max(0,(Y-X)))

elif A + B > C*2 :
    print(2*C*min(X,Y) + A*max(0,(X-Y)) + B*max(0,(Y-X)))

else:
    print(A*X+B*Y)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

cost_temp = float('inf')

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

print(cost_temp)

Submission status: Accepted

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

na = 0
nb = 0
nab = 0

if a+b >= 2*ab:
  nab += 2*min(x, y)
  if x > y:
    if ab*2 >= a:
      na += x - int(nab/2)
    else:
      nab += 2*(x - int(nab/2))
  else:
    if ab*2 >= b:
      nb += y - int(nab/2)
    else:
      nab += 2*(y - int(nab/2))
else:
  na += x
  nb += y

print(na*a + nb*b + nab * ab)

Submission status: Accepted

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

#cのみが最安
# a より2cが安い場合
# b より2cが安い場合
# 共通部をcで買って
# a+b より2cが安い場合

# 2まいずついる共通部
bose = min(x,y)

bose_cost = 0
if a+b > 2*c:
    bose_cost = 2*c
else:
    bose_cost = a+b


remain = max(x,y) - min(x,y)
remain_cost = 0


remain_one_cost = 0
if x> y:
    remain_one_cost = a
else:
    remain_one_cost = b

remain_cost = 0
if remain_one_cost > 2*c:
    remain_cost = 2*c
else:
    remain_cost = remain_one_cost

result = bose * bose_cost + remain_cost * remain
print(result)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a, b, c, x, y = map(int, input().split())
ans = 0
if a+b > c*2:
    ans += min(x, y) * 2 * c
    if [a, b][[x, y].index(max(x, y))] > c*2:
        ans += (max(x, y) - min(x, y)) * 2 * c
    else:
        ans += (max(x, y) - min(x, y)) * [a, b][[x, y].index(max(x, y))]
else:
    ans = a*x + b*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(1,max(X,Y)+1):
    a = A*(X-i) if X-i>0 else 0
    b = B*(Y-i) if Y-i>0 else 0
    tmp = a+b+C*i*2
    ans = min(ans,tmp)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:

input_line =input()
input_line = input_line.rstrip().split(" ")

a = int(input_line[0])
b = int(input_line[1])
c = int(input_line[2])
x = int(input_line[3])
y = int(input_line[4])

list1=[]
for i in range(max(x,y)+1):
    if x-i<=0 and y-i<=0:
        cost = 2*c*i
        list1.append(cost)
        i +=1
        
    elif x-i<=0:
        cost = b*(y-i)+2*c*i
        list1.append(cost)
        i +=1
        
    elif y-i<=0:
        cost = a*(x-i)+2*c*i
        list1.append(cost)
        i +=1
    
    else:
        cost = a*(x-i)+b*(y-i)+2*c*i
        list1.append(cost)
        i +=1
    

print(min(list1))

Submission status: Accepted

Solution code:
A, B, C, X, Y = map(int, input().split())
temp = A * X + B * Y
while True:
    if min(X, Y) > 0:        
        X -= 1
        Y -= 1
        now = temp - A - B + 2 * C
        if min(temp, now) == temp:
            break
        else:
            temp = now
    elif max(X, Y) > 0:
        if X == 0:
            Y -= 1
            now = temp - B + 2 * C
            if min(temp, now) == temp:
                break
            else:
                temp = now
        else:
            X -= 1
            now = temp - A + 2 * C
            if min(temp, now) == temp:
                break
            else:
                temp = now
    else:
        break
print(temp)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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


if 2*C<A and 2*C<B:
	print(2*C*max([X,Y]))
elif 2*C<A:
	if X<Y:
		print(2*C*X+B*(Y-X))
	else:
		print(2*C*X)
elif 2*C<B:
	if Y<X:
		print(2*C*Y+A*(X-Y))
	else:
		print(2*C*Y)
elif 2*C<A+B:
	if Y<X:
		print(2*C*Y+A*(X-Y))
	else:
		print(2*C*X+B*(Y-X))

else:
	print(A*X+B*Y)

Submission status: Accepted

Solution code:
import re
import math

if __name__ == '__main__':

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

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

    print(ans)

Submission status: Accepted

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

candidate = []

candidate.append(C * X * 2 if X >= Y else C * X * 2 + B * (Y - X))
candidate.append(C * Y * 2 if X <= Y else C * Y * 2 + A *(X - Y))
candidate.append(A * X + B * Y)

print(min(candidate))

Submission status: Accepted

Solution code:
A, B, C, X, Y = map(int, input().split())
c = C / 2
money = 0
if X > Y:
    m = X
    M = A
    f = Y
    F = B
else:
    m = Y
    M = B
    f = X
    F = A

if A + B > 2 * C:
    money = C * f * 2
    m = m - f
    f = 0

if F > 2 * C: money += f * 2 * C
else: money += f * F

if M > 2 * C: money += m * 2 * C
else: money += m * M

print(money)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Zmax = max(X,Y)
Zmin = min(X,Y)
tot = 0

if A+B >= 2*C:
    if X >= Y:
        if A <= 2*C:
            tot = 2*Zmin *C + (Zmax-Zmin) * A
        else:
            tot = 2*Zmin *C + 2*(Zmax-Zmin) * C
    else:
        if B <= 2*C:
            tot = 2*Zmin *C + (Zmax-Zmin) * B
        else:
            tot = 2*Zmin *C + 2*(Zmax-Zmin) * C
else:
    tot = X*A + Y*B

print(tot)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A,B,c,a,b=map(int,input().split());print(min(c*max(a,b)*2,A*a+B*b,[A,B][a<b]*abs(a-b)+c*min(a,b)*2))

Submission status: Accepted

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

A, B, AB, an, bn = map(int, input().split())
L = []
L += [AB*max(an, bn)*2]
L += [A*an+B*bn]
if an < bn:
    L += [B*(bn-an) + AB*min(an, bn)*2]
else:
    L += [A*(an-bn) + AB*min(an, bn)*2]
print(min(L))

Submission status: Accepted

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

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

if x == y:
    pass
elif x > y:
    if a > 2 * c:
        total += 2 * c * (x - y)
    else:
        total += a * (x - y)
else:
    if b > 2 * c:
        total += 2 * c * (y - x)
    else:
        total += b * (y - x)

print(total)

Submission status: Accepted

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

v1 = A * X + B * Y
v2 = A * max(X-Y, 0) + B * max(Y-X, 0) + C * 2 * min(X, Y)
v3 = C * 2 * max(X, Y)

print(min(v1, v2, v3))

Submission status: Accepted

Solution code:
A, B, C, X, Y = map(int, input().split())
 
c = min(A + B, C * 2)
a = min(c, A)
b = min(c, B)
 
xy = min(X, Y)
 
print (xy * c + (X - xy) * a + (Y - xy) * b)

Submission status: Accepted

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

C = min(2 * C, A + B)
A = min(A, C)
B = min(B, C)

Z = min(X,Y)

print( Z * C + (X-Z) * A + (Y-Z) * B)

Submission status: Accepted

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

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

print(cost)

Submission status: Accepted

Solution code:
input_data=input()
new_input = input_data.split(" ")
# print(new_input)
A=int(new_input[0])
B=int(new_input[1])
C=int(new_input[2])
X=int(new_input[3])
Y=int(new_input[4])
min_num=min([X,Y])

#混合で作る場合
if min_num * (A+B) > min_num * 2 * C:
    price = min_num * 2* C
else:
    price = min_num*(A+B)

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

print(price)

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    A, B, C, X, Y = list(map(int, input().split()))
    if A + B <= 2 * C:
        # print(1)
        print(A * X + B * Y)
    else:
        if X == Y:
            # print(2)
            print(C * 2 * X)
        elif X < Y:
            # print(3)
            print(min(X * C * 2 + B * (Y - X), C * 2 * Y))
        else:
            # print(4)
            print(min(Y * C * 2 + A * (X - Y), C * 2 * X))

Submission status: Accepted

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

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

print(min_cost)

Submission status: Accepted

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

cost1 = X * A + Y * B

c = X * 2
a = 0
b = max([0, Y - c / 2])
cost2 = a * A + b * B + c * C

c = Y * 2
a = max([0, X - c / 2])
b = 0
cost3 = a * A + b * B + c * C

print(int(min([cost1, cost2, cost3])))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
p = [int(x) for x in input().split()]

A = p[0]
B = p[1]
C = p[2]
X = p[3]
Y = p[4]

total = 0

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

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

print(total)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

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

# 処理
ans = [i * 2*C + max(0, X-i)*A + max(0, Y-i)*B for i in range(0, 100001)]

# 出力
print(min(ans))

Submission status: Accepted

Solution code:
a,b,c,x,y=[int(x) for x in input().split()]
def gauss(it):
    return max(it,0)
print(min([a*x+b*y,2*c*max(x,y),2*c*min(x,y)+a*gauss(x-min(x,y))+b*gauss(y-min(x,y))]))

Submission status: Accepted

Solution code:
l = raw_input().split()
A = int(l[0])
B = int(l[1])
C = int(l[2])
X = int(l[3])
Y = int(l[4])

cost = 0

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

print(cost)

Submission status: Accepted

Solution code:
a,b,c,x,y=input().split()
a=int(a)
b=int(b)
c=int(c)
x=int(x)
y=int(y)
ans = 5000 * 100000 * 3 * 2
ans1 = a*x+b*y
ans2 = a*max(0,x-y)+c*2*y
ans3 = b*max(0,y-x)+c*2*x
print(min([ans1, ans2, ans3]))

Submission status: Accepted

Solution code:
l = list(input().split())
c = 0
for i in l:
 l[c] = int(i)
 c+=1

k = min(l[3],l[4])
money = min((l[0]+l[1])*k, l[2]*2*k)

if l[3]>l[4]:
 m = l[3]-l[4]
 money += min(l[0], l[2]*2)*m
else:
 m = l[4]-l[3]
 money += min(l[1], l[2]*2)*m

print(money)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A, B, C, X, Y = [int(x) for x in raw_input().split()]
s = 0
p = min(X, Y)
X -= p
Y -= p
s += p * min(A+B, 2*C)
s += X * min(A, 2*C)
s += Y * min(B, 2*C)
print s

Submission status: Accepted

Solution code:
def compare(q,p):
    if q>p:
        return p
    else:
        return q
a,b,c,x,y= map(int, input().split())
re=0
if a+b>2*c:
    if x>y:
        re=compare(c*x*2,c*y*2+a*(x-y))
    else:
        re=compare(c*y*2,c*x*2+b*(y-x))
else:
    re=a*x+b*y
print(re)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
#Half and Half
A,B,C,X,Y=map(int,input().split())
if X>=Y:
    more=X
    more_price=A
    less=Y
else:
    more=Y
    more_price=B
    less=X
if more_price>=C*2:
    price=C*2*more
else:
    if A+B>=2*C:
            price=C*2*less+(more-less)*more_price
        
    else:
        price=A*X+B*Y
print(price)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
ABCXY = [int(i) for i in input().split()]
A, B, C, X, Y = ABCXY[0], ABCXY[1], ABCXY[2], ABCXY[3], ABCXY[4]
ans = 0

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

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

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

print(ans)

Submission status: Accepted

Solution code:
A,B,C,X,Y=map(int,input().split())
price = 0
a,b,c=0,0,0
if 2*C<=A:
    c+=X*2
    Y=max(0, Y-X)
    X=0
    
if 2*C<=B:
    c+=Y*2
    X=max(0, X-Y)
    Y=0
if C*2 < A+B:
    cc = min(X,Y)
    c+=cc*2
    X=max(0,X-cc)
    Y=max(0,Y-cc)
a=X
b=Y
print(A*a+B*b+C*c)

Submission status: Accepted

Solution code:
a, b, ab, x, y = (int(i) for i in input().split())
costcut = a + b - 2*ab
if costcut<=0:
    total = a*x + b*y
else:
    base = min(x,y)*2*ab
    nokori = abs(x-y)
    if x>y:
        if a>2*ab:
            total = base + nokori*2*ab
        else:
            total = base + nokori*a
    else:
        if b>2*ab:
            total = base + nokori*2*ab
        else:
            total = base + nokori*b
print(total)

Submission status: Accepted

Solution code:
a_yen , b_yen, c_yen , a_count,b_count = map(int,input().split())

abmax = max(a_count, b_count)
c_count = 0
kouhopiza = a_yen * a_count + b_yen * b_count + c_yen * c_count

while c_count <= 2*abmax:
    if kouhopiza > a_yen * a_count + b_yen * b_count + c_yen * c_count and a_count > -1 and b_count > -1:
        kouhopiza = a_yen * a_count + b_yen * b_count + c_yen * c_count
    elif a_count > -1 and b_count < 0:
        if kouhopiza > a_yen * a_count + c_yen * c_count:
            kouhopiza = a_yen * a_count + c_yen * c_count
    elif a_count < 0 and b_count > -1:
        if kouhopiza > b_yen * b_count + c_yen * c_count:
            kouhopiza = b_yen * b_count + c_yen * c_count
        
    c_count = c_count + 2
    a_count = a_count - 1
    b_count = b_count - 1
print(kouhopiza)