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:
def n():
    A, B, C, X, Y = map(int, input().split())
    ab = A + B
    cc = C * 2
    cost = 0
    if ab > cc:
        minn = min(X, Y)
        cost += minn * cc
    else:
        minn = min(X, Y)
        cost += minn * A + minn * B

    if X > Y:
        diff = X - Y
        aaa = A * diff
        ccc = cc * diff
        cost += min(aaa, ccc)
    else:
        diff = Y - X
        bbb = B * diff
        ccc = cc * diff
        cost += min(bbb,ccc)

    return cost


print(n())

Submission status: Accepted

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

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

Submission status: Accepted

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

    max_c = max([X,Y]) * 2
    yen = [0 for _ in range(max_c+1)]
    for c in range(max_c+1):
        x = X - c//2
        if x < 0:
            x = 0
        y = Y - c//2
        if y < 0:
            y = 0
        yen[c] = x*A + y*B + c*C
    return min(yen)

if __name__ == '__main__':
    print(main())

Submission status: Accepted

Solution code:
import sys
if __name__ == "__main__":
    A, B, C, X, Y = list(map(int, (input().split(' '))))
    cost_A = A * X
    cost_B = B * Y
    least_cost = cost_A + cost_B
    max_cnt = 0
    if X >= Y:
        max_cnt = X
    else:
        max_cnt = Y
    for i in range(0, 2*max_cnt+1, 2):
#        print(i)
        buf_cost_A = 0
        buf_cost_B = 0
        buf_cost = C * i
        if (X - i*0.5) > 0:
            buf_cost_A = (X - i*0.5) * A
        if (Y - i*0.5) > 0:
            buf_cost_B = (Y - i*0.5) * B
#        print(buf_cost+buf_cost_A+buf_cost_B)
        if least_cost > (buf_cost + buf_cost_A + buf_cost_B):
            least_cost = buf_cost + buf_cost_A + buf_cost_B
    print(int(least_cost))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
A,B,C,X,Y = map(int, input().split())
minAB = min(X,Y)
maxAB = max(X,Y) - minAB
ans = 0
# C2枚のほうがお得
if A + B > C * 2:
    ans = minAB * C * 2
else:
    ans = minAB * A + minAB * B

# X or Y の残りをCと比較して計算
if X > Y:
    # C2枚のほうがお得
    if A > C * 2:
        ans += maxAB * C * 2
    else:
        ans += maxAB * A
else:
    # C2枚のほうがお得
    if B > C * 2:
        ans += maxAB * C * 2
    else:
        ans += maxAB * B

print(ans)

Submission status: Accepted

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

#print A, B, C, X, Y

currentX = X
currentY = Y
currentH = 0

#print cost_A, cost_B
while (currentX>0)or(currentY>0):
    if currentX > 0:
        tmpX = currentX - 1
    if currentY > 0:
        tmpY = currentY - 1
    if ((tmpX * A) +(tmpY * B) +((currentH + 2) * C)) < ((currentX * A) +(currentY * B) +((currentH) * C)):
        if currentX > 0:
            currentX -= 1
        if currentY > 0:
            currentY -= 1
        currentH += 2
    else:
        break

#print ((currentX * A) +(currentY * B) +((currentH) * C)),currentX, currentY, currentH
print ((currentX * A) +(currentY * B) +((currentH) * C))

Submission status: Accepted

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

d = abs(x-y)
count=0
if (a+b) >= 2*c:
    count += 2*c*min(x,y)
else:
    count += (a+b)*min(x,y)

if x>=y:
    if a >= 2*c:
        count += 2*c*d
    else:
        count += a*d
else:
    if b >= 2*c:
        count += 2*c*d
    else:
        count += b*d

print(count)

Submission status: Accepted

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

print(ans)

Submission status: Accepted

Solution code:
a,b,c,x,y=map(int,input().split())
if x<y:
  min,max=x,y
  a2,b2=a,b
else:
  min,max=y,x
  a2,b2=b,a

if c*2<=a2+b2:
  res=2*min*c
  tmp1=(max-min)*b2
  tmp2=2*(max-min)*c
  if tmp1<tmp2:
    print(res+tmp1)
  else:
    print(res+tmp2)
else:
  if a2>b2:
    a2,b2=b2,a2
    min,max=max,min
  tmp1=a2*min+b2*max
  tmp2=2*max*c
  if min>max:
    tmp2+=(min-max)*a2
  if tmp1<tmp2:
    print(tmp1)
  else:
    print(tmp2)

Submission status: Accepted

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

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

print sum

Submission status: Accepted

Solution code:
A, B, C, X, Y = map(int, input().split())
ans = 0
if A+B > 2*C:
   min_v = min(X, Y)
   ans += C * min_v * 2
   diff = abs(X - Y)
   base = A if X > Y else B
   if base * diff < C * 2 * diff:
      ans += base * diff
   else:
      ans += C * 2 * diff
else:
   print(A*X + B*Y)
   exit()
print(ans)

Submission status: Accepted

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

ans = 10**1000

dat3 = [0, x*2,y*2]

for cc in dat3:
  aa = x - cc/2
  if aa < 0:aa = 0
  bb = y - cc/2
  if bb < 0:bb=0
  p = aa*a + bb*b + cc*c
  if p < ans:
    ans = p
print ans

Submission status: Accepted

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

# AtCoder Beginner Contest
# Problem C

if __name__ == '__main__':
    a, b, c, x, y = list(map(int, input().split()))
    ab_yen = a + b
    c_yen = 2 * c
    min_x_y_count = min(x, y)
    cost = 0

    if ab_yen >= c_yen:
        cost += c_yen * min_x_y_count
        cost += min(a, c_yen) * (x - min_x_y_count)
        cost += min(b, c_yen) * (y - min_x_y_count)
    else:
        cost = (a * x) + (b * y)

    print(cost)

Submission status: Accepted

Solution code:
def smaller(m, n):
	if m < n: return m
	else: return n

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

smallerpizza = smaller(X, Y)
morepizza = X + Y - 2*smallerpizza
neededpizza = ''
if smallerpizza == X: neededpizza = 'B'
else: neededpizza = 'A'

cost1 = A + B
if 2 * C < cost1: cost1 = 2 * C
cost2 = 0
if neededpizza == 'A': cost2 = A
if neededpizza == 'B': cost2 = B
if 2 * C < cost2: cost2 = 2 * C

print cost1 * smallerpizza + cost2 * morepizza

Submission status: Accepted

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

price = a*x + b*y
a_num = x
b_num = y

while True:
	if a_num > 0:
		a_num -= 1
		next_price = price - a
	if b_num > 0:
		b_num -= 1
		next_price = next_price - b

	next_price = next_price + c*2
	if next_price < price:
		price = next_price
	else:
		print(price)
		break

Submission status: Accepted

Solution code:
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().strip()

a,b,c,x,y = na()
tot = c*2
ans = 0
if a+b <= tot:
    ans = a*x + b*y
else:
    if a > tot and b > tot:
        mi = min(x,y)
        ans = mi*2*c + (max(x,y) - mi)*2*c
    elif a > tot and b <= tot:
        mi = min(x,y)
        if mi == x:
            ans = mi*2*c + (max(x,y) - mi)*b
        else:
            ans = mi*2*c + (max(x,y) - mi)*2*c
    elif a <= tot and b > tot:
        mi = min(x,y)
        if mi == x:
            ans = mi*2*c + (max(x,y) - mi)*2*c
        else:
            ans = mi*2*c + (max(x,y) - mi)*a
    else:
        mi = min(x,y)
        if mi == x:
            ans = mi*2*c + (max(x,y) - mi)*b
        else:
            ans = mi*2*c + (max(x,y) - mi)*a
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

if (a + b)/2 > c :
    price_min = c * min(x,y) * 2
    price_max = c * max(x,y) * 2

    if x-y > 0:
        price = a*(x-y) + price_min
    else:
        price = b*(y-x) + price_min

    if price > price_max:
        ans = price_max
    else:
        ans = price

else:
    ans = a * x + b * y

print(ans)

Submission status: Accepted

Solution code:
cols = input('').split()

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

total_ab = x * a + b * y

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

print(min(total_ab, total_ac, total_bc))

Submission status: Accepted

Solution code:
# coding: utf-8

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

# ABピザはAとBの平均より安いか
mean_AB = (A + B) / 2

if mean_AB > C:
    if X <= Y:
        price = C * X * 2 + B * (Y-X)
        # ABピザがかなり安く、余りが出ても多めに買ってもよい場合か
        price_AB = C * Y * 2
        if price_AB < price:
            price = price_AB
    else:
        price = C * Y * 2 + A * (X-Y)
        # ABピザがかなり安く、余りが出ても多めに買ってもよい場合か
        price_AB = C * X * 2
        if price_AB < price:
            price = price_AB

else:
    price = A * X + B * Y

print(price)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

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

    else:
        cost = cost + C*2*Y
        if 2 * C <= A:
            cost = cost + 2 * C * (X - Y)
            print(cost)
            exit()
        else:
            cost = cost + A * (X - Y)
            print(cost)
            exit()

else:  #A+B > 2C
    if min(X, Y) == X:
        cost = cost + 2 * C * X
        if 2 * C <= B:
            cost = cost + 2 * C * (Y - X)
            print(cost)
            exit()
        else:
            cost = cost + B * (Y - X)
            print(cost)
            exit()

    else:
        cost = cost + C * 2 * Y
        if 2 * C <= A:
            cost = cost + 2 * C * (X - Y)
            print(cost)
            exit()
        else:
            cost = cost + A * (X - Y)
            print(cost)
            exit()

Submission status: Accepted

Solution code:
import sys
A,B,C,X,Y = map(int,input().split())
ans = 0
if A+B > 2*C:
    judge = True
else:
    ans += X*A
    ans += Y*B
    print(ans)
    sys.exit()

    # judge = False

if judge:
    min_XY = min(X,Y)
    if min_XY == 0:
        ans += X*A
        ans += Y*B
        print(ans)
        sys.exit()
    else:
        X -= min_XY
        Y -= min_XY
        ans += 2*C*min_XY
        if X !=0:
            if 2*C*X < A*X:
                ans +=  2*C*X
            else:
                ans += A*X
        if Y !=0:
            if 2*C*Y < B*Y:
                ans +=  2*C*Y
            else:
                ans += B*Y
    print(ans)

Submission status: Accepted

Solution code:
# coding: UTF-8
import math
a,b,c,d,e = map(int, input().split())
flag = 0
flaga = 0
flagb = 0
cost = 0
if(a+b< 2*c):
    cost = a*d + b*e
    flag = 1
if(2*c<=a):
    flaga = 1#aが余ったらc2枚買えばいい
if(2*c<=b):
    flagb = 1#bが余ったらc2枚買えばいい

if(flag == 0):#同じ枚数分はcを買う
    if(d<=e):#bを追加で買わな
        if(flagb == 1):
            cost += e * 2 * c
        else:
            cost += d * 2 * c + (e-d)*b
    else:
        if(flaga == 1):
            cost += d * 2 * c
        else:
            cost += e * 2 * c + (d-e)*a
print(cost)

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

Submission status: Accepted

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

ans = 0
dic = {x:a,y:b}

if a+b < 2*c:
    ans += a*x + b*y

else:
    n = dic[max(x,y)]
    k = min(x,y)
    
    ans += 2*c*k
    
    if n >= 2*c:
        ans += (max(x,y)-k)*2*c
        
    else:
        ans += (max(x,y)-k)*n

print(ans)

Submission status: Accepted

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

# A,B,C,X,Yを取得
a, b, c, x, y = map(int, input().split())

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

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

# 結果を出力
print("{}".format(price))

Submission status: Accepted

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

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

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

print(price)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
#■標準入力ショートカット


def get_next_int():
    return int(float(input()))


def get_next_ints(delim=" "):
    return tuple([int(float(x)) for x in input().split(delim)])


def get_next_str():
    return input()


def get_next_strs(delim=" "):
    return tuple(input().split(delim))


def get_next_by_types(*value_types, delim=" "):
    return tuple([t(x) for t, x in zip(value_types, input().split(delim))])


def solve():
    A, B, C, X, Y = get_next_ints()

    proper = (A * X) + B * Y
    if X > Y:
        smaller = Y
        remainder = X - Y
        value = A
    else:
        smaller = X
        remainder = Y - X
        value = B
    mixed = C * smaller * 2 + min(remainder * value, remainder * C * 2)

    print(min(proper, mixed))


solve()

Submission status: Accepted

Solution code:
def read_line(*types): return [f(a) for a, f in zip(input().split(), types)]

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

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

Submission status: Accepted

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

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

if x > y:
  total1 += (x-y) * a
elif y > x:
  total1 += (y-x) * b

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

print(min(total1, total2))

Submission status: Accepted

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

Submission status: Accepted

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

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)
elif (a+b)>2*c:
    if x==y:
        print(2*x*c)
    elif x<y:
        if b>2*c:
            print(c*2*y)
        else:    
            print(2*x*c+b*(y-x))
    else:
        if a>2*c:
            print(c*2*x)
        else:    
            print(2*y*c+a*(x-y))

Submission status: Accepted

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

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

ab_max_pairs = max(x, y)

price_min = 1000000000

for i in range(ab_max_pairs + 1):
    price = c * i * 2 + max(0, (x-i)) * a + max(0, (y-i)) * b
    if price < price_min:
        price_min = price

print(price_min)

Submission status: Accepted

Solution code:
a, b, c, x, y = map(int, input().split())
ans = 0
maxxy = max(x,y)
minxy = min(x,y)
abcost = a * minxy + b * minxy
ccost = c * minxy * 2
ans += min(abcost, ccost)
amari = maxxy - minxy
if x > y:
    acost = a * amari
    ccost = c * amari * 2
    ans += min(acost, ccost)
elif x < y:
    bcost = b * amari
    ccost = c * amari * 2
    ans += min(bcost, ccost)

print(ans)

Submission status: Accepted

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

k = 0 #価格
if c*2 < a+b:
    z = min([x,y])
    k += z*c*2
    x -= z
    y -= z

if c*2 < a: k += x*c*2
else: k += x*a
    
if c*2 < b: k += y*c*2
else: k += y*b

print(k)

Submission status: Accepted

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

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

m = []

#Cを買わない
m.append(A*X + B*Y)

#Aを買い足す
if X > Y:
    m.append( (X-Y)*A + 2*Y*C )
#Bを買い足す
if X < Y:
    m.append( (Y-X)*B + 2*X*C )
#Cだけ買う
if X < Y:
    m.append(2*Y*C)
elif X == Y:
    m.append(2*Y*C)
else:
    m.append(2*X*C)

print(min(m))

Submission status: Accepted

Solution code:
from sys import stdin


def main():
    A, B, C, X, Y = [int(x) for x in stdin.readline().rstrip().split()]
    if A + B <= C * 2:
        print(A * X + B * Y)
    elif X < Y:
        spam = C * 2 * X
        if B < C * 2:
            print(B * (Y - X) + spam)
        else:
            print(C * 2 * (Y - X) + spam)
    else:
        spam = C * 2 * Y
        if A < C * 2:
            print(A * (X - Y) + spam)
        else:
            print(C * 2 * (X - Y) + spam)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

A_p = A * X
B_p = B * Y
justAB = A_p + B_p

min_x_y = min(X, Y)
AB_p = int((min_x_y / 0.5 * AB))

dif = 0
dif_p = 0
if X > Y:
    dif = X - Y
    dif_p = dif * A
else:
    dif = Y - X
    dif_p = dif * B


max_x_y = max(X,Y)
AB_max_p = int(max_x_y / 0.5 * AB)

print(min(justAB, AB_p + dif_p, AB_max_p))

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

mi = min(x,y)
sa = abs(x-y)
if c*2 <= a+b:
    daikin = c*2*mi
    if x >= y:
        piza = min(c*2,a)
        daikin += piza*sa
    else:
        piza = min(c*2,b)
        daikin += piza*sa
    print(daikin)
else:
    print(a*x + b*y)

Submission status: Accepted

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

cost_AplusB = min(A+B, 2*C)
costA = min(A, 2*C)
costB = min(B, 2*C)

flag = (X > Y)
many_pizza = max(X, Y)
few_pizza = min(X, Y)



price = cost_AplusB * few_pizza
if flag:
    price += costA * (many_pizza - few_pizza)
else:
    price += costB  * (many_pizza - few_pizza)

print(price)

Submission status: Accepted

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

price = 0

if x - y > 0:
    diff = x - y
    n_same = y
    rest_pr = a
else:
    diff = y - x
    n_same = x
    rest_pr = b


if a + b < c * 2:
    price += (a+b) * n_same
else:
    price += c * n_same * 2

if rest_pr < c * 2:
    price += rest_pr * diff
else:
    price += c * diff * 2

print(price)

Submission status: Accepted

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

    # A, B, C, X, Y = map(int, "1500 2000 1600 3 2".split())
    # A, B, C, X, Y = map(int, "1500 2000 1900 3 2".split())
    # A, B, C, X, Y = map(int, "1500 2000 500 90000 100000".split())

    # not buy AB
    if A + B < 2 * C:
        total = A * X + B * Y
        print(total)
        exit(0)

    # buy AB
    n_c_at_least = 2 * min(X, Y)

    X, Y = X - n_c_at_least // 2, Y - n_c_at_least // 2
    total = C * n_c_at_least

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

    print(total)

Submission status: Accepted

Solution code:
A, B, C, X, Y = map(int,input().split())
Sum=[0 for i in range(max(X,Y)+1)]


for AB in range(0, 2*max(X,Y)+1,2):
    Sum[AB//2]=max((X-AB//2),0)*A+max((Y-AB//2),0)*B+AB*C

print(min(Sum))

Submission status: Accepted

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

Submission status: Accepted

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

d = abs(x - y)
price = 0
num = 0
if x > y:
    if a <= 2 * c:
        price += d * a
        num = y
    else:
        price += d * 2 * c
        num = y
else:
    if b <= 2 * c:
        price += d * b
        num = x
    else:
        price += d * 2 * c
        num = x



if (a+b) >= 2*c:
    price += 2 * c * num
else:
    price += (a+b) * num

print(price)

Submission status: Accepted

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

Submission status: Accepted

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

price = 0
if c >= (a + b) / 2:
    price += a * x + b * y

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

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

print(price)

Submission status: Accepted

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

val1=A*X+B*Y

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

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

print min(val1,val2,val3)

Submission status: Accepted

Solution code:
import sys

def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline

def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [A, B, C, X, Y] = [int(input_raw[0]), int(input_raw[1]), int(input_raw[2]), int(input_raw[3]), int(input_raw[4])]

    min_cost = sys.maxint
    for c in range(max(X, Y) * 2 + 1):
        a = max(int((X - 0.5 * c) + 0.5), 0)
        b = max(int((Y - 0.5 * c) + 0.5), 0)
        cost = a * A + b * B + c * C
        if cost < min_cost:
            min_cost = cost
    print min_cost

if __name__ == '__main__':
    main()

Submission status: Accepted

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

# if a+b > c:
max_num = max(x,y)
cost_1 = max_num*2*c
# print(cost_1)
min_num = min(x,y)
cost_2 = (x-min_num)*a + (y-min_num)*b + c*2*min_num

cost_3 = (x*a + y*b)
# print(cost_2)
print(min(cost_3,min(cost_1,cost_2)))
# else:
#     print(a*x + b*y)

Submission status: Accepted

Solution code:
def c_half_and_half(A, B, C, X, Y):
    if X <= Y:
        tmp = X * 2 * C + (Y - X) * B
    else:
        tmp = Y * 2 * C + (X - Y) * A
    ans = min(tmp, max(X, Y) * 2 * C, X * A + Y * B)
    return ans

A,B,C,X,Y = [int(i) for i in input().split()]
print(c_half_and_half(A, B, C, X, Y))

Submission status: Accepted

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

c = c * 2

total = 0

minimum = min(x,y)

if a + b > c:
  total += minimum * c
  x -= minimum
  y -= minimum

if x > 0:
  if a > c:
    total += x * c
  else:
    total += x * a

if y > 0:
  if b > c:
    total += y * c
  else:
    total += y * b

print(total)

Submission status: Accepted

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

m = min([X,Y])
M = max([X,Y])
d = abs(X-Y)
if A+B < 2*C:
  res = X*A + Y*B
elif X < Y:
  if 2*C*X + B*(Y-X) < 2*C*Y:
    res = 2*C*X + B*(Y-X)
  else:
    res = 2*C*Y
else:
  if 2*C*Y + A*(X-Y) < 2*C*X:
    res = 2*C*Y + A*(X-Y)
  else:
    res = 2*C*X

print(res)

Submission status: Accepted

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

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

ans2 = x * a + y * b

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

print(min(ans1, ans2, ans3))

Submission status: Accepted

Solution code:
a, b, ab, x, y = (int(i) for i in input().split())  
if a + b <= (ab * 2):
    print(a*x+b*y)
else:
    num_ab = min(x,y)*2
    price = 0
    price += num_ab*ab + (x-num_ab/2)*a + (y-num_ab/2)*b
    price2 = 0
    price2 += max(x,y)*ab*2
    print(int(min(price,price2)//1))

Submission status: Accepted

Solution code:
A,B,C,X,Y = map(int, input().split())
Z = X-Y
if Z<0:
  AB_least = min([X,Y])*2*C + abs(Z)*B
else:
  AB_least = min([X,Y])*2*C + Z*A
AB_all = max([X,Y])*2*C
AandB = A*X + B*Y
ans = min([AB_least,AB_all,AandB])
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
A, B, C, X, Y = map(int, input().split())
com = min(X, Y)
min_cost = min(A+B, C*2)

if min_cost * max(X, Y) < min_cost * com  + A * (X - com) + B * (Y - com):
    print(min_cost * max(X, Y))
else:
    print(min_cost * com  + A * (X - com) + B * (Y - com))

Submission status: Accepted

Solution code:
money_a, money_b, money_c, num_a, num_b = [int(x) for x in input().strip().split()]
sum_money = list()
temp = 0
for _ in range(num_a):
    temp += money_a
for _ in range(num_b):
    temp += money_b
sum_money.append(temp)
temp = 0
for _ in range(min(num_a, num_b)):
    temp += money_c*2
if num_a > num_b:
    temp += money_a * (num_a-num_b)
elif num_a < num_b:
    temp += money_b * (num_b-num_a)
sum_money.append(temp)
temp = 0
for _ in range(max(num_a, num_b)):
    temp += money_c*2
sum_money.append(temp)
print(min(sum_money))

Submission status: Accepted

Solution code:
import sys

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

if A+B < 2*C:
    print(A*X+B*Y)
else:
    pre = []
    pre.append(max(X,Y)*2*C)
    if X>Y:
        #X>YならY枚Bピザを用意してX-Y枚Aピザを買うのも候補
        pre.append(Y*2*C+(X-Y)*A)
    elif X<Y:
        #X枚Aピザを用意してY-X枚Bピザ
        pre.append(X*2*C+(Y-X)*B)
    else:

        pre.append(Y*2*C+(X-Y)*A)
        pre.append(X*2*C+(Y-X)*B)
    print(min(pre))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
input_conditions = input().split()

price_a = int(input_conditions[0])
price_b = int(input_conditions[1])
price_ab = int(input_conditions[2])
required_a = int(input_conditions[3])
required_b = int(input_conditions[4])

price_1 = price_a * required_a + price_b * required_b

if required_a > required_b:
    price_2 = price_ab * required_b * 2 + price_a * (required_a - required_b)
else:
    price_2 = price_ab * required_a * 2 + price_b * (required_b - required_a)

price_3 = price_ab * max(required_a, required_b) * 2

print(min(price_1, price_2, price_3))

Submission status: Accepted

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