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())

totalA1 = A * X
totalA2 = C * X * 2
totalB1 = B * Y
totalB2 = C * Y * 2

totalAB = A * X + B * Y

totalAC = C * Y * 2
if X > Y:
    totalAC += (X - Y) * A

totalCB = C * X * 2
if Y > X:
    totalCB += (Y - X) * B

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

print(min(totalAB, totalAC, totalCB, totalCC))

Submission status: Accepted

Solution code:
import sys

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

price = 0
another = sys.maxsize

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

Submission status: Accepted

Solution code:
A = [int(i) for i in input().split(' ')]
if 2*A[2] < A[0] + A[1]:
  m = min(A[3], A[4])
  print(A[2] * m * 2 + (A[3] - m)*min(A[0],2*A[2]) + (A[4] - m)*min(A[1],2*A[2]) )
else:
  print(A[3] * A[0] + A[4] * A[1])

Submission status: Accepted

Solution code:
A, B, C, X, Y = [int(x) for x in input().split()]
maxAB = max(X, Y)
min = 2*maxAB*C+1

for i in range(maxAB+1):
    numA = max(X-i, 0)
    numB = max(Y-i, 0)
    value = numA*A+numB*B+2*i*C
    if value < min:
        min = value

print(min)

Submission status: Accepted

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

#abset==ab num *2
anss = []
for abset in range(max(X,Y)+1):
	anss.append(abset*2*C+max(0,X-abset)*A+max(0,Y-abset)*B)
				
print(min(anss))

Submission status: Accepted

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

Submission status: Accepted

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

import sys

lst = list(map(int, input().split()))

a_value = lst[0]
b_value = lst[1]
c_value = lst[2]
a_number = lst[3]
b_number = lst[4]

value = 0

if a_value + b_value <= c_value * 2:
    value = a_value * a_number + b_value * b_number
    print (value)
else:
    if a_number >= b_number:
        value += c_value * 2 * b_number
        if (a_number - b_number) * a_value >= (a_number - b_number) * c_value * 2:
            value += (a_number - b_number) * c_value * 2
        else:
            value += (a_number - b_number) * a_value

    else:
        value += c_value * 2 * a_number
        if (b_number - a_number) * b_value >= (b_number - a_number) * c_value * 2:
            value += (b_number - a_number) * c_value * 2
        else:
            value += (b_number - a_number) * b_value
    print (value)

Submission status: Accepted

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

def r(a, b, c, x, y):
    if x == 0 and y == 0:
        return 0
    if x == 0:
        return min(y*b, 2*y*c)
    if y == 0:
        return min(x*a, 2*x*c)
    if (a + b) / 2 < c:
        return a*x+b*y
    else:
        z = min(x, y) * 2
        x = x - z/2
        y = y - z/2
        return r(a, b, c, x, y) + z*c


print(int(r(A, B, C, X, Y)))

Submission status: Accepted

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

strat1 = A*X + B*Y  # simple strategy
strat2 = 2*C*X + abs(Y-X)*B  # more A, add back B
strat3 = 2*C*Y + abs(X-Y)*A  # more B, add back A
strat4 = 2*C*max(X,Y) # overbuy C

print min(strat1, strat2, strat3, strat4)

Submission status: Accepted

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

Submission status: Accepted

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

# xの方が多い状態にする
if x<y:
    a,b,x,y = b,a,y,x

min_price = 1000000000000
# +1を忘れるとWA
for i in range(x+1):
    # 残り枚数がマイナスにならないようにmaxを取る
    need = max(0,(x-i))*a + max(0,(y-i))*b + 2*i*c
    min_price = min(min_price, need)    
print(min_price)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Tue Mar  5 17:16:53 2019

@author: yuta
"""

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

def main(a,b,c,x,y):
    if a + b - 2*c > 0:
    #min(x,y)
        set_num_min = min(x,y)
        price_min = set_num_min * 2*c #セット分
        price_min += a * max(0,x-set_num_min) #Aの残り分
        price_min += b * max(0,y-set_num_min) #Bの残り分
    #max(x,y)
        set_num_max = max(x,y)
        price_max = set_num_max * 2*c #セット分
        print(min(price_min,price_max))
    else:
        price = a*x + b*y
        print(price)
main(A,B,C,X,Y)

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

print(ans)

Submission status: Accepted

Solution code:
A, B, C, X, Y = map(int, input().split())
if X < Y:
    cn = range(Y+1)
    p = X
else:
    cn = range(X+1)
    p = Y
min_price = A*X + B*Y
for i in cn:
    if i <= p:
        price = (A*(X-i)+C*i)+(B*(Y-i)+C*i)
        if min_price > price:
            min_price = price
    else:
        if p == X:
            price = C*i+(B*(Y-i)+C*i)
            if min_price > price:
                min_price = price
        else:
            price = (A*(X-i)+C*i) + C*i
            if min_price > price:
                min_price = price
print(min_price)

Submission status: Accepted

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

a1=A*X+B*Y
a2=C*max(X,Y)*2
a3=C*min(X,Y)*2+max((X-min(X,Y))*A,(Y-min(X,Y))*B)

print(min([a1,a2,a3]))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

l = a+b-2*c

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

Submission status: Accepted

Solution code:
A,B,C,X,Y = map(int,input().split(" "))
list = []
list.append(A*X+B*Y)
less = min(X,Y)
if X > Y:
    list.append(2*C*less + A * (X - less))
else:
    list.append(2*C*less + B * (Y - less))
more = max(X,Y)
if X > Y:
    list.append(2*C*more)
else:
    list.append(2*C*more)
print(min(list))

Submission status: Accepted

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

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

Submission status: Accepted

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

yen = float('inf')
for nc in range(max(x, y) * 2, -2, -2):
    na = max(0, x - nc//2)
    nb = max(0, y - nc//2)
    tmp = na * a + nb * b + nc * c
    if tmp < yen:
        yen = tmp

print(yen)

Submission status: Accepted

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

if a > 2*c:
    total += 2 * c * x
    y -= x
    x = 0

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

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

print(total)

Submission status: Accepted

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

cost = min(list(max(0,(X-c//2))*A+max(0,(Y-c//2))*B+c*C for c in range(0,2*max(X,Y)+1)))
print(cost)

Submission status: Accepted

Solution code:
# _*_ coding:utf-8 _*_
#  Atcoder_Regurar_Contest096-C
#  https://atcoder.jp/contests/arc096/tasks/arc096_a
import sys
def solveProblem(priceA,priceB,priceABSet,wantA,wantB):
	minPrice = sys.maxsize
	for buyABSet in range(0,200000+1,+2):
		# ABピザで補えるAピザとBピザの量
		alreadyA = buyABSet//2
		alreadyB = buyABSet//2
		moreWantA = wantA-alreadyA
		moreWantB = wantB-alreadyB
		# さらに必要となるピザの枚数:もう要らないなら0枚、いるならその枚数
		#　ピザA
		if moreWantA <=0 :
			getA = 0
		else :
			getA = moreWantA
		# ピザB
		if moreWantB <= 0:
			getB = 0
		else:
			getB = moreWantB
		needMoney = priceA * getA + priceB * getB + priceABSet * buyABSet
		if needMoney <= minPrice:
			minPrice = needMoney
	answer = minPrice
	return answer

if __name__ == '__main__':
	A,B,C,X,Y = map(int,input().strip().split(' '))
	solution = solveProblem(A,B,C,X,Y)
	print("{}".format(solution))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys


def input():
    return sys.stdin.readline()[:-1]


def ii(t: type = int):
    return t(input())


def il(t: type = int):
    return list(map(t, input().split()))


def imi(N: int, t: type = int):
    return [ii(t) for _ in range(N)]


def iml(N: int, t: type = int):
    return [il(t) for _ in range(N)]


A, B, C, X, Y = il()

if A + B < 2 * C:
    print(A * X + B * Y)
    exit()
p = min(X, Y) * 2 * C
n = max(X - Y, Y - X)
if X < Y:
    p += min(2 * C * n, n * B)
else:
    p += min(2 * C * n, n * A)
print(p)

Submission status: Accepted

Solution code:
import sys


def input():
    return sys.stdin.readline()[:-1]


def ii(t: type = int):
    return t(input())


def il(t: type = int):
    return list(map(t, input().split()))


def imi(N: int, t: type = int):
    return [ii(t) for _ in range(N)]


def iml(N: int, t: type = int):
    return [il(t) for _ in range(N)]


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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy
A, B, C, X, Y = map(int, raw_input().split())
min_idx = numpy.argmin([X, Y])
max_idx = numpy.argmax([X, Y])
cost = 0
if A + B > 2 * C:
    cost += 2 * C * min(X, Y)
else:
    cost += (A + B) * min(X, Y)
if [A, B][max_idx] > 2 * C:
    cost += 2 * C * (max(X, Y) - min(X, Y))
else:
    cost += [A, B][max_idx] * (max(X, Y) - min(X, Y))
print cost

Submission status: Accepted

Solution code:
A,B,C,X,Y = map(int,input().split())
p=5000000000
for i in list(range(0,max([X+1,Y+1]))):
    if p > max([X-i,0])*A+max([Y-i,0])*B+2*C*i:
        p=max([X-i,0])*A+max([Y-i,0])*B+2*C*i
print(p)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b,c,x,y=map(int,input().split())
n=a*x+b*y
M=max(x,y)
m=min(x,y)
d1=c*M*2
d2=c*m*2+(x-m)*a+(y-m)*b
print(min(n,d1,d2))

Submission status: Accepted

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

if __name__=='__main__':
    a, b, c, x, y = list(map(int, input().split()))
    half = c/2
    pizza = 0

    if a + b < 2*c:
        pizza = a*x + b*y
    else:
        m = min(x, y)
        n = max(x, y)
        pizza = 2*c*m

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

    print(pizza)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
A, B, C, X, Y = list(map(int, input().split(' ')))
x = X
y = Y
ans = 0
flag = True
if X > Y:
    flag = False
if A+B >= 2*C:
    if flag:
        ans += X * 2*C
        x -= X
        y -= X
    else:
        ans += Y * 2*C
        x -= Y
        y -= Y

ans += x*min(A, 2*C)
ans += y*min(B, 2*C)

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A, B, C, X, Y = list(map(int, input().strip().split()))
costmin = 5e9
for i in range(100001):
	cost = 0
	cost += i*C*2
	if X > i:
		cost += A*(X-i)
	if Y > i:
		cost += B*(Y-i)
	if cost < costmin:
		costmin = cost
print(costmin)

Submission status: Accepted

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

p = [
    2 * c * x + b * max(y-x, 0),
    2 * c * y + a * max(x-y, 0),
    a * x + b * y
]

print(min(p))

Submission status: Accepted

Solution code:
def main():
    a,b,c,x,y = [int(i) for i in input().split()]
    ans = 1 << 32
    if x < y:
        tmp = 2*x*c
        tmp += (y-x)*b
        ans = min(tmp,ans)
    else:
        tmp = 2*y*c
        tmp += (x-y)*a
        ans = min(tmp,ans)
    if a//2+b//2 < c:
        ans = x*a+ y*b
    ans=min(ans,2*max(x,y)*c)
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

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


sum1 = 0
sum1 = A * X + B * Y

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

sum3 = 0
sum3 = C * max(X, Y) * 2

print(min(sum1, sum2, sum3))

Submission status: Accepted

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

ans = []

for z in range(0,max(X+1, Y+1)*2, 2):
    x = max(X - z//2, 0)
    y = max(Y - z//2, 0)
    ans.append((A * x) + (B * y) + (C * z))

print(min(ans))

Submission status: Accepted

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

if X > Y:
	print(min(A + B, C) * Y + min(A, C) * (X - Y))

else:
	print(min(A + B, C) * X + min(B, C) * (Y - X))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def inpl(): return [int(i) for i in input().split()]

A, B, C, X, Y = inpl()

print(min(A*X + B*Y,min(X,Y)*2*C + (X - min(X,Y))*A +(Y - min(X,Y))*B ,max(X,Y)*2*C))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A, B, C, X, Y = map(int, input().split())
num = float("inf")
for i in range(0, 2 * 10 ** 5 + 3, 2):
    num = min(num, A * max(0, X - i // 2) + B * max(0, Y - i // 2) + C * i)
print(num)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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
    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: Accepted

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

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

Submission status: Accepted

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)]>=float(x+y)/2:print(a*x+b*y-min(x,y)*(a+b-2*c))
else:print(max(x,y)*2*c)

Submission status: Accepted

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

print(money)

Submission status: Accepted

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 += B * (Y-X)
    elif X==Y:
        total += 2*C * X
print(total)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
N = list(map(int,input().split(" ")))
"""
for i in range(0,X+Y+1):
    for j in range(0,X+1):
        for k in range(0,Y+1):
            A2 = i/2
            B2 = i/2
            if A2+j == X and B2+k == Y:
                print(A*j+B*k+C*i)

"""
C = 0
ABC = N[0:3]
if ABC[2] != max(ABC) and abs(min(ABC) - ABC[2]) < abs(max(ABC) - ABC[2]):
    R = []
    AB = N[3]+N[4]+(abs(N[3]-N[4]))
    for i in range(AB+1):
        C=0
        A = i/2
        B = i/2
        C+=ABC[2]*i
        if A % 1 == 0.0 and B % 1 == 0.0:
            if N[3] > int(A) and (N[3]-A)*ABC[0] >= 0:
                C+=(N[3]-int(A))*ABC[0]
                A+=N[3] - int(A)
            if N[4] > int(B) and (N[4]-B)*ABC[1] >= 0:
                C+=(N[4]-int(B))*ABC[1]
                B+=N[4] - int(B)
            if A >= N[3] and B >= N[4]:
                R.append(C)
    print(int(min(R)))
else:
    print(ABC[0]*N[3]+ABC[1]*N[4])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

    if a > 0:
        if A > 2*C:
            c += 2*a
            a = 0
    elif b > 0:
        if B > 2*C:
            c += 2*b
            b = 0

print(a*A + b*B + c*C)

Submission status: Accepted

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

ABcheap=min(C*2,A+B)
Acheap=min(A,C*2)
Bcheap=min(B,C*2)
answer=0

while(True):
  if(X>=1 and Y>=1):
    answer+=ABcheap
    X-=1
    Y-=1
  elif(X>=1 and Y==0):
    answer+=Acheap
    X-=1
  elif(X==0 and Y>=1):
    answer+=Bcheap
    Y-=1
  else:
    print(answer)
    exit()

Submission status: Accepted

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

min_price = 10000000000000000000000000001

for i in range(max(X, Y) + 1) :
    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)
    # int("DBG : ", cnt_a, cnt_b, i)
print(min_price)

Submission status: Accepted

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(min(ans1, ans2), ans3))

Submission status: Accepted

Solution code:
from sys import stdin, stdout


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

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

stdout.write(str(ans))

Submission status: Accepted

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

extra_pizza=max(X,Y)
surplus=max(X,Y)-min(X,Y)

number_of_pair=(X+Y-surplus)/2
money_sum=0

if number_of_pair*(A+B) > number_of_pair*2*C:
    money_sum+=number_of_pair*2*C
else:
    money_sum+=number_of_pair*(A+B)

if extra_pizza==X:
    if surplus*A > surplus*2*C:
        money_sum+=surplus*2*C
    else:
        money_sum+=surplus*A
else:
    if surplus*B > surplus*2*C:
        money_sum+=surplus*2*C
    else:
        money_sum+=surplus*B

print(int(money_sum))

Submission status: Accepted

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

Submission status: Accepted

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) * B
    c = 2 * Y * C
    
    res = min([a,b,c])
print(res)

Submission status: Accepted

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




u = c*min(x ,  y)*2
uu = max(x , y) * 2 * c
ans = min(u , min(x , y) * a + min(x,y)*b)


resx = x - min(x,y)
resy = y - min(x,y)

ans = ans + (resx * a) + (resy * b)
ans = min(ans  , uu)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

ans = []

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

Submission status: Accepted

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

all_ab = a*x + b* y
all_c = max(x,y) * 2 *c

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

# print(all_ab)
# print(all_c)
# print(mix_abc)

print(min(all_ab, all_c, mix_abc))

Submission status: Accepted

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

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

Submission status: Accepted

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 * d * 2

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

print(z)

Submission status: Accepted

Solution code:
# coding: utf-8
import sys


# 標準入力
data = tuple(map(int, sys.stdin.readline().strip().split(' ')))
aPizza = data[0]
bPizza = data[1]
cPizza = data[2]
x = data[3]
y = data[4]

cost = 0

# x y の枚数が
if (x != 0 and y != 0):
    sheets = (x if x < y else  y)
    if (aPizza + bPizza > cPizza * 2):
        cost = cost + cPizza * 2 * sheets
    else:
        cost = cost + (aPizza + bPizza) * sheets
    x = x - sheets
    y = y - sheets


if (x != 0):
    if (aPizza > cPizza * 2):
        cost = cost + cPizza * 2 * x
    else:
        cost = cost + aPizza * x

if (y != 0):
    if (bPizza > cPizza * 2):
        cost = cost + cPizza * 2 * y
    else:
        cost = cost + bPizza * y



# 標準出力
print(cost)

Submission status: Accepted

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

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

print(result)

Submission status: Accepted

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

total_price = 0

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

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

print(total_price)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(1000000)

A, B, C, X, Y = map(int, input().split())
# A, B, C, X, Y = 1500, 2000, 1600, 3, 2


def calcBestPrice(A, B, C, X, Y):

    if(X > 0 and Y > 0):
        if(A + B > 2 * C):
            return 2 * C + calcBestPrice(A, B, C, X - 1, Y - 1)
        elif(A > 2 * C):
            return 2 * C * X + calcBestPrice(A, B, C, 0, Y)
        elif(B > 2 * C):
            return 2 * C * Y + calcBestPrice(A, B, C, X, 0)
        else:
            return A * X + B * Y
    elif(X == 0):
        if(B > 2 * C):
            return 2 * C * Y
        else:
            return B * Y
    elif(Y == 0):
        if(A > 2 * C):
            return 2 * C * X
        else:
            return A * X


print(calcBestPrice(A, B, C, X, Y))

Submission status: Accepted

Solution code:
import os



inputs = str(input()).split(' ')
inputs = [int(i) for i in inputs]
A, B, C, X, Y = inputs


def cost(a, b, c):
	return a*A+b*B+c*C

cost_list = []
maxc = max([X*2, Y*2])
for i in range(0, maxc+1):
	c = i
	a = max([X - int(c/2), 0])
	b = max([Y - int(c/2), 0])
	cst = cost(a, b, c)
	cost_list.append(cst)

mincost = min(cost_list)
print(int(mincost), end='')

Submission status: Accepted

Solution code:
#!/usr/bin/python

import os
import sys

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

if A + B < C*2:
    print A * X + B * Y
    sys.exit()

tmp = min(X, Y)
if tmp == X:
    t1 = C*2*tmp+(Y-tmp)*B
else:
    t1 = C*2*tmp+(X-tmp)*A
t2 = max(X, Y)*C*2
print min(t1, t2)

Submission status: Accepted

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

if (A + B <= C * 2):
  print(A * X + B * Y)
else:
  #Aに合わせる
  price1 = C * 2 * X + B * max(Y - X, 0)
  #Bに合わせる
  price2 = C * 2 * Y + A * max(X - Y, 0)
  print(min(price1, price2))

Submission status: Accepted

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