Problem:


Score : 300 points

Problem Statement

"Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively.

Nakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas.

Constraints

1 ≤ A, B, C ≤ 5000

1 ≤ X, Y ≤ 10^5

All values in input are integers.

Input

Input is given from Standard Input in the following format:

A B C X Y

Output

Print the minimum amount of money required to prepare X A-pizzas and Y B-pizzas.

Sample Input 1

1500 2000 1600 3 2

Sample Output 1

7900

It is optimal to buy four AB-pizzas and rearrange them into two A-pizzas and two B-pizzas, then buy additional one A-pizza.

Sample Input 2

1500 2000 1900 3 2

Sample Output 2

8500

It is optimal to directly buy three A-pizzas and two B-pizzas.

Sample Input 3

1500 2000 500 90000 100000

Sample Output 3

100000000

It is optimal to buy 200000 AB-pizzas and rearrange them into 100000 A-pizzas and 100000 B-pizzas. We will have 10000 more A-pizzas than necessary, but that is fine.



Sample input:
1500 2000 1600 3 2


Sample output:
7900

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b,c,x,y = map(int,input().split())
fx = x
fy = y
fl = 0
val = int(0)
fmin = min(x,y)
if a>2*c:
  x = 0
  y = y - fx
  val += 2*c*fx
  fl += 1
if y < 0:
  y = 0
if b>2*c:
  if fl == 1:
    val += 2*c*y
    y = 0
  else:
    val += 2*c*y
    x = x -y
    y = 0 
if x < 0:
  x = 0
nx = x
ny = y
if a+b>2*c:
  x = x - min(nx,ny)
  y = y - min(nx,ny)
  val += 2*c*min(nx,ny)
print(val+a*x+b*y)

Submission status: Accepted

Solution code:
def main():
    """
    1 <= A,B,C<=5*10^3
    1 <= X,Y<=10^5
    """
    A, B, C, X, Y = map(int, input().split())

    # A,B片方をを愚直に用意
    # A,BをABから愚直に用意
    a4 = A * X + min(B * Y, 2 * C * Y)
    a5 = B * Y + min(A * X, 2 * C * X)
    a6 = 2 * C * max(X, Y)

    a1 = 2 * C * min(X, Y)
    d = abs(X - Y)
    price = A if X >= Y else B
    a1 += min(price * d, 2 * C * d)

    # ABからAを作る
    a2 = float("inf")
    if 2 * C < A:
        d = max(Y - X, 0)
        a2 = 2 * C * X + min(B * d, 2 * C * d)

    # ABからBを作る
    a3 = float("inf")
    if 2 * C < B:
        d = max(X - Y, 0)
        a3 = 2 * C * Y + min(A * d, 2 * C * d)

    ans = min([a1, a2, a3, a4, a5, a6])
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

if x >= y:
	i = a * (x - y) + c * y * 2
	j = a * x + b * y
	k = c * x * 2
	if i >= j and k >= j:
		count = j
	elif i >= k and j >= k:
		count = k
	elif j >= i and k >= i:
		count = i
else:
	i = b * (y - x) + c * x * 2
	j = a * x + b * y
	k = c * y * 2
	if i >= j and k >= j:
		count = j
	elif i >= k and j >= k:
		count = k
	elif j >= i and k >= i:
		count = i

print(count)

Submission status: Accepted

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

min_money=2*5000*10**5
for nc in range(0,2*10**5+1,2):
    if nc > 2*x and nc > 2*y:
        break
    if nc > 2*x:
        money = (y-nc//2)*b + nc*c
    elif nc > 2*y:
        money = (x-nc//2)*a + nc*c
    else:
        money = (x-nc//2)*a + (y-nc//2)*b + nc*c
    if min_money > money:
        min_money = money
            
print(min_money)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

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

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

a2 = min(x, y) * c * 2 + a * (x - min(x, y))+ b * (y - min(x, y))

a3 = a * x + b * y

answer = min(a1, a2, a3)
print(str(answer))

Submission status: Accepted

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

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

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

print(res)

Submission status: Accepted

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

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

rem_C = remain*C
rem_AorB = remain*(A,B)[X<Y]

if rem_C*2 < rem_AorB:
    ans += rem_C*2
else:
    ans += rem_AorB

print(ans)

Submission status: Accepted

Solution code:
A, B, C, X, Y = map(int, input().split())
pa = A * X
pb = B * Y
pab = pa + pb
pc_max = C * max(X, Y) * 2
pc_min = C * min(X, Y) * 2
if X > Y:
    n = X - Y
    pc_min += A * n
else:
    n = Y - X
    pc_min += B * n
print(min(pab, pc_max, pc_min))

Submission status: Accepted

Solution code:
if __name__ == "__main__":
    A, B, C, X, Y = list(map(int, input().split()))
    ans = 0
    if (A + B) >= 2*C:
        # ABピザ2枚買ってAとBに分けた方がお得
        if (A >= B):
            if (B >= 2*C):
                # 全部ABの方がお得
                if X >= Y:
                    ans += (2*C) * X
                    print(ans)
                    exit()
                else:
                    ans += (2*C) * Y
                    print(ans)
                    exit()
            elif (A >= 2*C):
                # Aの分はABピザで買ったほうがお得
                ans += (2*C) * X
                if Y >= X:
                    ans += A * (Y - X)
                print(ans)
                exit()
            else:
                # 枚数が少ない方をABで買う
                if X >= Y:
                    ans += (2*C) * Y
                    ans += A * (X - Y)
                else:
                    ans += (2*C) * X
                    ans += B * (Y - X)
                print(ans)
                exit()
        else:
            if (A >= 2*C):
                if X >= Y:
                    # 全部ABの方がお得
                    ans += (2*C) * X
                    print(ans)
                    exit()
                else:
                    # 全部ABの方がお得
                    ans += (2*C) * Y
                    print(ans)
                    exit()
            elif (B >= 2*C):
                # Bの分はABピザで買ったほうがお得
                ans += (2*C) * Y
                if X >= Y:
                    ans += A * (X - Y)
                print(ans)
                exit()
            else:
                # 枚数が少ない方をABで買う
                if X >= Y:
                    ans += (2*C) * Y
                    ans += A * (X - Y)
                else:
                    ans += (2*C) * X
                    ans += B * (Y - X)
                print(ans)
                exit()
    else:
        # 普通に買ったほうがよい
        ans += A * X + B * Y
        print(ans)
        exit()

Submission status: Accepted

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

Z = max(X,Y)
W = min(X,Y)

if Z % 2 == 1:
  Zeven = Z + 1
else:
  Zeven = Z

if W % 2 == 1:
  Weven = W + 1
else:
  Weven = W

# 個別
price1 = X*A + Y*B

# 全部Cで賄う（超えても良い）
price2 = C * Z * 2

# X,YのMAXが奇数の時、MAX-1までをCで賄う。端数はABでやる
if Z % 2 == 0:
  price3 = price2
else:
  price3 = C * (Z-1)*2 + A * max(0, X - Z + 1) + B * max(0,Y - Z + 1)

# 少ない方に合わせてCでまかない、端数はAかBでやる（超えるver)
price4 = C * W * 2 + A * max(0,X-W) + B * max(0,Y-W)

# 少ない方に合わせてCでまかない、端数はAかBでやる（超えないver)
if W % 2 == 0:
  price5 = price4
else:
  price5 = C * (W-1) * 2+ A * max(0,X - W + 1) + B * max(0,Y - W + 1)

#print(price1, price2, price3, price4, price5)
print(min(price1,price2,price3,price4,price5))

Submission status: Accepted

Solution code:
def a():
    s = input()
    total = 700
    for i in s:
        total += 100 if i == 'o' else 0
    print(total)


def b():
    n, x = map(int, input().split())
    m = [int(input()) for _ in range(n)]
    print(len(m) + ((x - sum(m)) // min(m)))


def c():
    a, b, c, x, y = map(int, input().split())
    total = 0
    while x > 0 or y > 0:
        # compare a, b, c
        xi = min(x, 1)  # 0, 1
        yi = min(y, 1)  # 0, 1
        x -= xi
        y -= yi
        total += min(xi*a+yi*b, 2*c)
        # if xi*a+yi*b < 2*c:
        #     print(f'A pizza * {xi}, B pizza * {yi}')
        # else:
        #     print('AB pizza * 2')
    print(total)


c()

Submission status: Accepted

Solution code:
def solve(a, b, c, x, y):
    i = div(x, 2)
    j = div(y, 2)
    m = a * i + b * j

    for k in range(1, max(x, y) + 1):
        i = div(x - k, 2)
        j = div(y - k, 2)
        m = min(m, a * i + b * j + c * k)
    
    return m


def div(x, y):
    if x <= 0:
        return 0

    n, r = divmod(x, y)
    if r != 0:
        return n + 1
    else:
        return n


def main():
    a, b, c, x, y = map(int, input().split())
    print(solve(a, b, c, x * 2, y * 2))

main()

Submission status: Accepted

Solution code:
l = input().split(' ')
a,b,c,x,y = int(l[0]),int(l[1]),int(l[2]),int(l[3]),int(l[4])

place = []
place.append( a * x + b * y )

if x-y > 0:
    place.append(c * x * 2)
else:
    place.append(c * y * 2)

if x < y :
    place.append(c * x * 2 + b * (y-x))
else :
    place.append(c * y * 2 + a * (x-y))
    
print(sorted(place)[0])

Submission status: Accepted

Solution code:
A, B, C, X, Y = [int(i) for i in input().split()]
ma = max(X, Y)
mi = min(X, Y)
memo = []
if A + B > 2 * C:
    result1 = A * (X - mi) + B * (Y - mi) + C * 2 * mi
    result2 = C * 2 * ma
    print(min(result1, result2))
else:
    print(A * X + B * Y)

Submission status: Accepted

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

price = 0

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

print(price)

Submission status: Accepted

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

print(sum)

Submission status: Accepted

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

for i in range(x+1):
    v = x-i
    s = a*i + b*(y-v) + c*v
    if y <= v:
        s = a*i + c*v
    if s < mi:
        mi = s

for i in range(y+1):
    v = y-i
    s = a*(x-v) + b*i + c*v
    if x <= v:
        s = b*y + c*v
    if s < mi:
        print('h', a*(x-v) + b*i + c*v)
        mi = s

if c*max((x,y)) < mi:
    mi = c*max((x,y))

print(mi)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    A, B, C, X, Y = (int(i) for i in input().split())
    if(A + B) <= C *2:
        print(A * X + B * Y)

    else:
        value = 0
        value = min(X, Y) * C * 2
        if (X - Y) >0:
            min_value = min(int(X - Y)*A, abs(X-Y)*C*2)
        else:
            min_value = min(int(Y - X)*B, abs(X-Y)*C*2)

        print(value + min_value)
if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

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

result = 0
while True:
    if X <= 0 and Y <= 0:
        break

    if X == 0 and C * 2 >= B:
        print(result + Y * B)
        exit()
    elif Y == 0 and C * 2 >= A:
        print(result + X * A)
        exit()

    result += C * 2
    X -= 1
    Y -= 1

print(result)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
da = list(map(int,input().split()))
oka = 0
o = 0
p = 0
l = 0
k = 0
if da[3] <= da[4]:
  oka = da[3]
  o = da[4]
  p = da[4]-da[3]
  l = 1
  k = 0
elif da[4] <= da[3]:
  oka = da[4]
  o = da[3]
  p = da[3]-da[4]
  l = 0
  k = 1
if (da[0]*da[3] + da[1]*da[4]) >= (da[2]*o*2 + da[k]*p):
  if da[3] <= da[4]:
    print(da[2]*da[4]*2)
  else:
    print(da[2]*da[3]*2)
elif (da[0]*da[3] + da[1]*da[4]) >= (da[2]*oka*2 + da[l]*p):
  if da[3] <= da[4]:
    print(da[2]*da[3]*2 + da[1]*(da[4]-da[3]))
  else:
    print(da[2]*da[4]*2 + da[0]*(da[3]-da[4]))
else:
  print(da[0] * da[3] + da[1] * da[4])

Submission status: Accepted

Solution code:
ABCXY = list(int(i) for i in input().split())

XY = []
XY.append(ABCXY[3])
XY.append(ABCXY[4])

ans = 0
if 2*ABCXY[2] < ABCXY[0] + ABCXY[1]:
    ans += min(XY)*2*ABCXY[2]
    if XY[0] > XY[1]:
        if ABCXY[0] < 2*ABCXY[2]:
            ans += (XY[0]-XY[1])*ABCXY[0]
        else:
            ans += (XY[0]-XY[1])*ABCXY[2]*2
    else:
        if ABCXY[1] < 2*ABCXY[2]:
            ans += (XY[1]-XY[0])*ABCXY[1]
        else:
            ans += (XY[1]-XY[0])*ABCXY[2]*2
else:
    ans += ABCXY[0]*XY[0] + ABCXY[1]*XY[1]
print(ans)

Submission status: Accepted

Solution code:
import sys
raw_input = sys.stdin.readline
range = xrange
a, b, c, x, y = map(int, raw_input().split())
if 2 * c >= a + b :
    print x * a + y * b
else:
    DP = [0]*(max(x, y)+1)
    for i in range(max(x, y)+1):
        DP[i] = 2 * c * i + a * max(0, x-i) + b * max(0, y-i)
    print min(DP)

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    a,b,c,x,y = map(int, raw_input().split())
    if c * 2 > a + b:
        print a * x + b * y
    else:
        cost = c * 2 * min(x,y)
        z = abs(x-y)
        if x < y :
            if c * 2 * z < b * z:
                print cost + c * 2 * z
            else:
                print cost + b * z
        else:
            if c * 2 * z < a * z:
                print cost + c * 2 * z
            else:
                print cost + a * z

Submission status: Accepted

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

Submission status: Accepted

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

price1 = X * A + Y * B
price2 = X * 2 * C + (Y - X) * B if Y > X else X * 2 * C
price3 = Y * 2 * C + (X - Y) * A if X > Y else Y * 2 * C
min_price = min(price1, price2, price3)

print(min_price)

Submission status: Accepted

Solution code:
a,b,c,x,y=list(map(int,input().split()))
mxy=min([x,y])
Mxy=max([x,y])
mab=min([a,b])
ans=0
if 2*c<a+b:
	ans+=2*c*mxy
	if x<y:
		ans+=b*(y-mxy)
	else:
		ans+=a*(x-mxy)
else:
	ans=a*x+b*y

if ans>2*c*Mxy:
	ans=2*c*Mxy

print(ans)

Submission status: Accepted

Solution code:
def getinputdata():

    # 配列初期化
    array_result = []    
    data = input()
    array_result.append(data.split(" "))

    flg = True

    try:
        while flg:

            data = input()

            array_temp = []

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = True

            else:

                flg = False
    finally:

        return array_result

arr_data = getinputdata()

#apizza
a = int(arr_data[0][0])
#bpizza
b = int(arr_data[0][1])
#abpizza
c = int(arr_data[0][2])

#apizzaの枚数
x = int(arr_data[0][3])

#bpizzaの枚数
y = int(arr_data[0][4])

mysum1 = a * x + b * y
mysum2 = c * max(x, y) * 2
mysum3 = c * min(x, y) * 2 + a * (x-min(x, y)) + b * (y-min(x, y))

arr=[mysum1,mysum2,mysum3]
arr.sort()
print(arr[0])

Submission status: Accepted

Solution code:
a_price, b_price, ab_price, a_want, b_want = list(map(int, input().split()))
ab_price = ab_price * 2
anb = a_price + b_price
ans = 0

def return_small_num(a, b):
	return min(a, b)


def remaining_amount_list(a, b, a_price, b_price):
	if a > b:
		return [a - b, a_price]
	else:
		return [b - a, b_price]


which = remaining_amount_list(a_want, b_want, a_price, b_price)

small_num = return_small_num(a_want, b_want)

# 絶対的な条件として、abの値段よりも単体の値段の方が小さいのであれば単体で全て賄うべきである
if anb <= ab_price:
	ans = a_want * a_price + b_want * b_price
# abで揃えたほうが、単体で購入するよりも安いのであれば必要最低限の数まではabで購入する
elif anb > ab_price:
	ans = ab_price * small_num
	# ここから更に条件分岐をする
	# 小さい方の数まで。つまり最低限の購入枚数を揃えたなら、その先は、単体で購入したほうがやすいかもしれない
	# その為、remaining_amount_list()を利用して条件分岐を行おう
	# whichの配列の1番目には値段がある。この値段がabより小さいならば、whichの０番目の個数分購入する
	# そうでないならwhichの０番目分をabで購入する
	remaining = which[0]
	amount = which[1]
	if amount <= ab_price:
		ans = ans + remaining * amount
	else:
		ans = ans + remaining * ab_price

print(ans)

Submission status: Accepted

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


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

print(money)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a, b, c, x, y = map(int, input().split())
#if a+b <= 2*c:  # aとbをそのまま買う
#    print(a*x + b*y)
#else:
#    if a >= 2*c and b >= 2*c:  # 全部ABピザにする
#        print(2*c * max(x, y))
#    else:
#        if x >= y:
#            print(2*c*y + a*(x-y))
#        else:
 #           print(2*c*x + b*(y-x))


ans = 0

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

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

print(ans)


# 10100 100 500 10 0

Submission status: Accepted

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

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

res += a*x + b*y
print(res)

Submission status: Accepted

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

price = min(A+B, 2*C) * min(X, Y)
need_A = max(0, X-Y)
need_B = max(0, Y-X)

if need_A > 0:
    price += need_A * min(A, 2*C)
if need_B > 0:
    price += need_B * min(B, 2*C)

print(price)

Submission status: Accepted

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

    sum = 100000000000000000000000000000000
    for i in range(0, max(X,Y)*2+2, 2):
        if X-i//2 < 0 and Y-i//2 >= 0:
            sum = min(sum, B*(Y-i//2) + C*i)
        elif X-i//2 >= 0 and Y-i//2 < 0:
            sum = min(sum, A*(X-i//2) +C*i)
        else:
            sum = min(sum, A*(X-i//2) + B*(Y-i//2) + C*i)
    print(sum)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

print(count)

Submission status: Accepted

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

smaller = X if X < Y else Y
bigger = X if X >= Y else Y
bigger_yen = A if bigger==X else B
cheaper = A if A <B else B
higher = A if A >= B else B

if 2*C >= A + B:
    buy = A*X + B*Y
elif 2*C < A + B:
    if bigger_yen < 2*C:
        buy = smaller*2*C + (bigger-smaller)*bigger_yen
    else:
        buy = bigger*2*C

print(buy)

Submission status: Accepted

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

print(s)

Submission status: Accepted

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

def main():
	a,b,c,x,y = map(int,input().split())
	if a+b < 2*c:
		# AピザとBピザ1枚ずつ用意するためにABピザ2枚より単体の方が安い場合
		print(a*x+b*y)
	else:
		# とりあえず必要数が少ない方に合わせて買う
		double = 2*c*min(x,y)
		if x < y:
			print((y-x)*min(b,2*c) + double)
		else:
			print((x-y)*min(a,2*c) + double)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

    case1 = A * X + B * Y
    case2 = C * 2 * max(X, Y)
    if X < Y:
        case3 = C * X * 2 + B * (Y - X)
    else:
        case3 = C * Y * 2 + A * (X - Y)
    ans = min(case1, case2, case3)

    print(ans)

main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

print(ans)

Submission status: Accepted

Solution code:
a,b,c,x,y = map(int,input().split())
s = 0
k = 2 * c
money = 0
s = min(a+b,k)
if k<a:
    a = k
if k<b:
    b = k
little = min(x,y)
money = little * s
x -= little
y -= little
if x:
    money += x*a
elif y:
    money += y*b
print(money)

Submission status: Accepted

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

ans = 0

if x<y:
    xy = x
    y -= x
    if b < 2*c:
        ans += b*y
    else:
        ans += 2*c*y

else:
    xy = y
    x -= y
    if a < 2*c:
        ans += a*x
    else:
        ans += 2*c*x

if a+b<2*c:
    ans += xy*(a+b)
else:
    ans += xy*(2*c)

print (ans)

Submission status: Accepted

Solution code:
def calc_ans(a,b,c,x,y):
    #2. candidate
    less = min([x,y])
    if less == y:
        use_c = 2*c*less + a*(x-less)
    else:
        use_c = 2*c*less + b*(y-less)
        
    not_use_c = a*x + b*y
    
    only_c = 2*c*max([x,y])
    
    return min([use_c, not_use_c, only_c])

def main():
    #1.input
    a,b,c,x,y = map(int, input().split())
    
    
    ans = calc_ans(a,b,c,x,y)
    print(ans)

if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys,collections;sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

A,B,C,x,y = Is()
ans = 10**10
for i in range(0,max(x*2,y*2)+3,2):
    a = max(0,(x - i//2)*A)
    b = max(0,(y - i//2)*B)
    c = i*C
    ans = min(a+b+c,ans)
print(ans)

Submission status: Accepted

Solution code:
# 入力

A, B, C, X, Y=map(int, input().split())
numA=0
numB=0
numC=0
answer=0

if A>2*C:
    #Aを買うくらいならCを2個買うべき
    answer+=2*X*C #ABピザを、Aを充足する分購入する
    numC+=2*X
    Y-=X #その分Bも買った
    X=0

if B>2*C and Y>0:
    #Bを買うくらいならCを2個買うべき
    answer+=2*Y*C #ABピザを、Bを充足する分購入する
    numC+=2*Y
    X-=Y #その分Aも買った
    Y=0

if X>0 or Y>0: #まだどちらかを買う必要があるなら
    if A+B>2*C: #AとBを1個ずつ買うくらいならCを2個買うべき
        answer+=2*min(X, Y)*C
        numC+=2*min(X, Y)
        m=min(X, Y)
        X-=m
        Y-=m

    answer+=A*X+B*Y
    numA+=X
    numB+=Y

# print('A:'+str(numA)+' B:'+str(numB)+' C:'+str(numC))
print(answer)

Submission status: Accepted

Solution code:
A, B, C, X, Y = map(int, input().split())
price = 0
P = []
s = 0
t = 0
u = 0
if A + B <= 2*C:
    price = A*X + B*Y
else:
    sa = abs(X - Y)
    price = C*2*(min(X, Y)-sa)
    XX = X - (min(X, Y)-sa)
    YY = Y - (min(X, Y)-sa)
    dai = max(XX, YY)
    syou = min(XX, YY)

    for i in range(dai+1):
        u = i*2
        if syou>=i:
            s = XX - i
            t = YY - i
        else:
            if X >= Y:
                s = XX - i
                t = 0
            else:
                s = 0
                t = YY - i
        P.append(A*s + B*t + C*u)
    price += min(P)

print(price)

Submission status: Accepted

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

n = min(x, y)
p1 = min(n*a+n*b, 2*n*c)

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

Submission status: Accepted

Solution code:
l = list(map(int,input().split()))
a,b,c,x,y = l[0],l[1],l[2],l[3],l[4]
ans = 0
minxy = min(x,y)
maxxy = max(x,y)
if maxxy == x:
    remab = a
elif maxxy == y:
    remab = b
rem = maxxy - minxy
if a + b >= 2*c:
    ans += 2*minxy*c
else:
    ans += minxy*(a+b)
if rem == 0:
    print(ans)
else:
    if 2*c <= remab:
        ans += 2*rem*c
    else:
        ans += rem*remab
    print(ans)

Submission status: Accepted

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

if y > x:
    o = c*min(x,y)*2 + b*abs(x-y)
else:
    o = c*min(x,y)*2 + a*abs(x-y)
p = a*x + b*y
q = c*max(x,y)*2

print(min(o,p,q))

Submission status: Accepted

Solution code:
a,b,c,x,y = list(map(int,input().split()))
ret = 0
if a+b > c*2:
    targetPizza = 0
    if x>y:
        x -= y
        ret += y*c*2
        y = 0
        if c*2 < a:
            ret += c*2*x
            x = 0

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

Submission status: Accepted

Solution code:
a,b,c,x,y = map(int,input().split())
cou = 0
lis = []
lis.append(a * x + b * y)
lis.append(max(x,y) * 2 * c)
nu = min(x,y)
cou += min(x,y) * 2 * c
x -= nu
y -= nu
cou += x * a + y * b
lis.append(cou)

print(min(lis))

Submission status: Accepted

Solution code:
s = list(map(int, input().split()))
a, b, c, x, y = s[0], s[1], s[2], s[3], s[4]
pa = 0
pb = 0
res = 10**10
for i in range(0, 2*(x+y+1), 2):
 t = i*c+(x-min(x, i//2))*a+(y-min(y, i//2))*b
 if t<res:
  res = t

print(res)

Submission status: Accepted

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

Submission status: Accepted

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

def main(a, b, c, x, y):

    # min(a * A + b * B + c * C)
    # A + C/2 >= x
    # B + C/2 >= y
    m = []
    # 全部AとB
    m.append(a * x + b * y)
    # 全部C
    m.append(c * max(x, y) * 2)
    # xの方が多くて途中からA
    if x >= y: m.append(c * min(x, y) * 2 + a * (x - y))
    if x < y: m.append(c * min(x, y) * 2 + b * (y - x))
    print(min(m))
    


if __name__ == '__main__':
    try:
        a, b, c, x, y = list(map(int, input().strip().split(' ')))
        main(a, b, c, x, y)
    except EOFError:
        pass

Submission status: Accepted

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

Submission status: Accepted

Solution code:
list1=list(map(int,input().split()))
a=list1[0]
b=list1[1]
c=list1[2]
x=list1[3]
y=list1[4]
if x >= y:
    p = min(a * x + b * y , c * 2 * x , c * 2 * y + a * (x - y))
else:
    p = min(a * x + b * y , c * 2 * y , c * 2 * x + b * (y - x))
print(p)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Sat Apr 21 21:25:13 2018

@author: Kim
"""

IN = input().split()
A = int(IN[0])
B = int(IN[1])
C = int(IN[2])
X = int(IN[3])
Y = int(IN[4])

#そのまま買う
As = A * X
Bs = B * Y
ALLSUM = As + Bs

#ハーフをどちらかに合わせる
Cmax = 2 * max(X,Y) * C
Cmin = 2 * min(X,Y) * C

#ハーフの場合で小さい方に合わせた時の差分とその額
sabunkosuu = max(X,Y) - min(X,Y)
if X > Y:
    sabungaku = A * sabunkosuu
elif X < Y:
    sabungaku = B * sabunkosuu
else:
    sabungaku = 0

#そしてそれを足した時の額
halfmin = Cmin + sabungaku 

#全部比べる
ANS = min(ALLSUM, Cmax, halfmin)
print(ANS)

Submission status: Accepted

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

cost1 = x * a + y * b

if x > y:
    price = a
else:
    price = b

cost2 = min(x, y) * 2 * c + (max(x, y) - min(x, y)) * price

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

print(min(cost1,cost2,cost3))