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: Time Limit Exceeded

Solution code:


a,b,c,x,y = map(int,input().split())
p_lists = []
#print(a,b,c,x,y)

if x > y:
  d = x
else:
  d = y

#print(d)

for i in range(x + 1):
    for j in range(y + 1):
        for k in range(2 * d + 1):
            if (i + k / 2 >= x and j + k / 2 >= y):
                price = a * i + b * j + c * k
                maxprice = a * x + b * y
                if price <= maxprice:
                    p_lists.append(price)      



#print(p_lists)
print(min(p_lists))

Submission status: Time Limit Exceeded

Solution code:


a,b,c,x,y = map(int,input().split())
p_lists = []
#print(a,b,c,x,y)

if x > y:
  d = x
else:
  d = y

#print(d)

for i in range(x + 1):
    for j in range(y + 1):
        for k in range(2 * d + 1):
            if (i + k / 2 >= x and j + k / 2 >= y):
                price = a * i + b * j + c * k
                p_lists.append(price)      



#print(p_lists)
print(min(p_lists))

Submission status: Time Limit Exceeded

Solution code:
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines

def main():
    a, b, c, x, y = map(int, input().split())
    r = float('inf')
    for piza_a in range(x + 1):
        for piza_b in range(y + 1):
            piza_c = max(x - piza_a, y - piza_b) * 2
            tmp = piza_a * a + piza_b * b + piza_c * c
            r = min(r, tmp)
    print(r)

if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
#W, H, x, y, r = map(int, input().split())
def main():
    a, b, c, x, y = map(int, input().split())

    min_sum = 100000 * 5000 + 100000 * 5000 + 200000 * 5000

    if a == c and b == c :
        min_sum = a * x + b * y
    elif a  < c and b < c  or a  == c and b  < c or a < c and b  == c :
        min_sum = a * x + b * y
    elif a  > c and b  > c or a  == c and b  > c or a  > c and b  == c  :
        if x >= y :
            min_sum = y * 2 * c
            if a > c * 2:
                min_sum = min_sum + (x - y) * c * 2
            else:
                min_sum = min_sum + (x - y ) * a
        else:
            min_sum = x * 2 * c
            if b > c * 2:
                min_sum = min_sum + (y - x) * c * 2
            else:
                min_sum = min_sum + (y - x ) * b
    else:
        for i in range(0, x+1):
            for j in range(0, y+1):
                if min_sum > a * i + b * j + max(x-i, y-j) * c * 2:
                    min_sum =a * i + b * j + max(x-i, y-j) * c * 2

    print(min_sum)
main()
# if a >= c and b <= c :
#     sum = x * c * 2
#     if x <= y :
#         sum = sum + ( y - x ) * b
# else:
#     sum = y * c * 2
#     if x >= y :
#         sum = sum + ( x - y ) * a


# if b > c * 2 :
    #     b_price = c
    #
    # input_array_list = []
    #
    # while True:
    #     input_array = input().split()
    #     if input_array[0] == "0" and input_array[1] == "0":
    #         break
    #     else:
    #         input_array_list.append(input_array)
    #
    # for item in input_array_list:
    #     n = int(item[0])
    #     k_sum = int(item[1])
    #
    #     count = 0
    #     for i in range(1,n + 1- 2):
    #         for j in range(i+1, n + 1 - 1):
    #             for k in range (j+1, n+ 1):
    #                 if i + j + k == k_sum :
    #                     count = count + 1
    #     print(count)

    #
    # for item in input_array_list:
    #     if item[1] == "+":
    #         print(str(int(item[0])+int(item[2])))
    #     elif item[1] =="-":
    #         print(str(int(item[0])-int(item[2])))
    #     elif item[1] == "/":
    #         print(str(int(item[0])//int(item[2])))
    #     elif item[1] == "*":
    #         print(str(int(item[0])*int(item[2])))
    #

# import sympy as sp

# input_list = []
# a,b,c = map(int, input().split())
# divisors = sp.divisors(c)
#
# count = 0
#
# for divisor in divisors:
#     if a <= divisor and divisor <= b:
#         count = count + 1
# print(count)
#
# while True:
#     pair_str = input().split()
#     pair_int = [int(s) for s in pair_str]
#     if pair_int[0] == 0 and pair_int[1] == 0 :
#         break
#     else:
#         input_list.append(pair_int)
#
# for pair_int in input_list:
#     if pair_int[0] <= pair_int[1]:
#         print("{} {}".format(pair_int[0], pair_int[1]))
#     else:
#         print("{} {}".format(pair_int[1], pair_int[0]))

#for i in range(10000):
#    print("Hello World")
#a = input().split()
#a_int = [int(s) for s in a]
#a_sorted = sorted(a_int)
#print(' '.join(map(str, a_sorted)))

Submission status: Time Limit Exceeded

Solution code:
#W, H, x, y, r = map(int, input().split())
def main():
    a, b, c, x, y = map(int, input().split())

    min_sum = 100000 * 5000 + 100000 * 5000 + 200000 * 5000

    if a == c and b == c :
        min_sum = a * x + b * y
    elif a  < c and b < c  :
        min_sum = a * x + b * y
    elif a  > c and b  > c or a  == c and b  > c or a  > c and b  == c  :
        if x >= y :
            min_sum = y * 2 * c
            if a > c * 2:
                min_sum = min_sum + (x - y) * c * 2
            else:
                min_sum = min_sum + (x - y ) * a
        else:
            min_sum = x * 2 * c
            if b > c * 2:
                min_sum = min_sum + (y - x) * c * 2
            else:
                min_sum = min_sum + (y - x ) * b
    else:
        for i in range(0, x+1):
            for j in range(0, y+1):
                if min_sum > a * i + b * j + max(x-i, y-j) * c * 2:
                    min_sum =a * i + b * j + max(x-i, y-j) * c * 2

    print(min_sum)
main()
# if a >= c and b <= c :
#     sum = x * c * 2
#     if x <= y :
#         sum = sum + ( y - x ) * b
# else:
#     sum = y * c * 2
#     if x >= y :
#         sum = sum + ( x - y ) * a


# if b > c * 2 :
    #     b_price = c
    #
    # input_array_list = []
    #
    # while True:
    #     input_array = input().split()
    #     if input_array[0] == "0" and input_array[1] == "0":
    #         break
    #     else:
    #         input_array_list.append(input_array)
    #
    # for item in input_array_list:
    #     n = int(item[0])
    #     k_sum = int(item[1])
    #
    #     count = 0
    #     for i in range(1,n + 1- 2):
    #         for j in range(i+1, n + 1 - 1):
    #             for k in range (j+1, n+ 1):
    #                 if i + j + k == k_sum :
    #                     count = count + 1
    #     print(count)

    #
    # for item in input_array_list:
    #     if item[1] == "+":
    #         print(str(int(item[0])+int(item[2])))
    #     elif item[1] =="-":
    #         print(str(int(item[0])-int(item[2])))
    #     elif item[1] == "/":
    #         print(str(int(item[0])//int(item[2])))
    #     elif item[1] == "*":
    #         print(str(int(item[0])*int(item[2])))
    #

# import sympy as sp

# input_list = []
# a,b,c = map(int, input().split())
# divisors = sp.divisors(c)
#
# count = 0
#
# for divisor in divisors:
#     if a <= divisor and divisor <= b:
#         count = count + 1
# print(count)
#
# while True:
#     pair_str = input().split()
#     pair_int = [int(s) for s in pair_str]
#     if pair_int[0] == 0 and pair_int[1] == 0 :
#         break
#     else:
#         input_list.append(pair_int)
#
# for pair_int in input_list:
#     if pair_int[0] <= pair_int[1]:
#         print("{} {}".format(pair_int[0], pair_int[1]))
#     else:
#         print("{} {}".format(pair_int[1], pair_int[0]))

#for i in range(10000):
#    print("Hello World")
#a = input().split()
#a_int = [int(s) for s in a]
#a_sorted = sorted(a_int)
#print(' '.join(map(str, a_sorted)))

Submission status: Time Limit Exceeded

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

    min_sum = 100000 * 5000 + 100000 * 5000 + 200000 * 5000

    if a == c and b == c :
        min_sum = a * x + b * y
    elif a  < c and b < c  :
        min_sum = a * x + b * y
    elif a  > c and b  > c  :
        if x >= y :
            min_sum = y * 2 * c
            if a > c * 2:
                min_sum = min_sum + (x - y) * c * 2
            else:
                min_sum = min_sum + (x - y ) * a
        else:
            min_sum = x * 2 * c
            if b > c * 2:
                min_sum = min_sum + (y - x) * c * 2
            else:
                min_sum = min_sum + (y - x ) * b
    else:
        for i in range(0, x+1):
            for j in range(0, y+1):
                if min_sum > a * i + b * j + max(x-i, y-j) * c * 2:
                    min_sum =a * i + b * j + max(x-i, y-j) * c * 2

    print(min_sum)
main()

Submission status: Time Limit Exceeded

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

    min_sum = 100000 * 5000 + 100000 * 5000 + 200000 * 5000

    if a == c and b == c :
        min_sum = a * x + b * y
    if a  < c and b < c  :
        min_sum = a * x + b * y
    elif a  > c and b  > c  :
        if x >= y :
            min_sum = y * 2 * c
            if a > c * 2:
                min_sum = min_sum + (x - y) * c * 2 
            else:
                min_sum = min_sum + (x - y ) * a
        else:
            min_sum = x * 2 * c
            if b > c * 2:
                min_sum = min_sum + (y - x) * c * 2 
            else:
                min_sum = min_sum + (y - x ) * b
    else:
        for i in range(0, x+1):
            for j in range(0, y+1):

                if min_sum > a * i + b * j + max(x-i, y-j) * c * 2:
                    min_sum =a * i + b * j + max(x-i, y-j) * c * 2

    print(min_sum)
main()

Submission status: Time Limit Exceeded

Solution code:
A,B,C,X,Y=map(int,input().split())
if A>=2*C:
  if B>=2*C:
    print(2*C*max(X,Y))
    exit()
  else:
    print(2*C*X+B*max(0,(Y-X)))
    exit()
elif B>=2*C:
  print(2*C*Y+A*max(0,(X-Y)))
  exit()
else:
  ans=A*X+B*Y
  for p in range(X):
    for q in range(Y):
      r=max(2*(X-p),2*(Y-q))
      ans=min(ans,A*p+B*q+C*r)
  print(ans)

Submission status: Time Limit Exceeded

Solution code:
A,B,C,X,Y = map(int,input().split())
ans = 100000000000000000000000000000000000000
for c in range (max(2*X,2**Y)):
  price = A*max(0,X-(0.5*c))+B*max(0,Y-(0.5*c))+C*c
  if price < ans:
    ans = price
print(int(ans))

Submission status: Time Limit Exceeded

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

price = X * A + Y * B
for a in range(X+1):
    for b in range(Y+1):
        c = max(X-a,Y-b)*2
        price = min(price,a*A + b*B + c*C)

print(price)

Submission status: Time Limit Exceeded

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

# Aピザをi枚Bピザをj枚買う
for i in range(x+1):
    for j in range(y+1):
        # cピザを買う必要のある枚数
        k = max(x-i,y-j)*2
        # 合計金額
        ans = min(ans,i*a+j*b+k*c)

print(ans)

Submission status: Time Limit Exceeded

Solution code:
a,b,c,x,y = map(int,input().split())
c = c*2
n = max(x,y)
ans = 10**25
for i in range(10**10):
    x1,y1 = i,i
    p = c*i
    if x > x1:
        if y > y1:
            p += a*(x-x1) + b*(y-y1)
        else:
            p += a*(x-x1)
    else:
        if y > y1:
            p += b*(y+y1)
    if ans > p:
        ans = p

print(ans)

Submission status: Time Limit Exceeded

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

ans = float('inf')

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

for x in range(X + 1):
    for y in range(Y + 1):
        c = max(X - x, Y - y)
        p = x * A + y * B + (2 * c) * C
        ans = min(ans, p)

print(ans)

Submission status: Time Limit Exceeded

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

cost = 1e+12
for i in range(x+1):
  for j in range(y+1):
    z = max(x-i, y-j) * 2
    cost = min(cost, A * i + B * j + C * z)
print(cost)

Submission status: Time Limit Exceeded

Solution code:
a,b,c,x,y = map(int,input().split())
A_B = a*x+b*y
AB = 2*c*max(x,y)
A_AB = 10**11111111
AB_B = 10**11111111
if x-y > 0:
  A_AB = a*(x-y)+2*c*y
if y-x > 0:
  AB_B = 2*c*x+b*(y-x)

ans = min(A_B,A_AB,AB_B,AB)
print(ans)

Submission status: Time Limit Exceeded

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

ans = max(x,y)*2*c
s = max(x,y)

while True:
    tmp = 0
    tmp -= c*2
    s -= 1
    if x > s:
        tmp += a
    if y > s:
        tmp += b
    if tmp > 0:
        print(ans)
        exit()
    else:
        ans += tmp

Submission status: Time Limit Exceeded

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

for a in range(0,X+1):
  for b in range(0,Y+1):
    c_num = max( 2*(X-a), 2*(Y-b) )
    P= A*a + B*b + C*c_num
    mini=min(mini,P)
    
print(mini)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

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

    dp = [[0 for i in range(Y+1)] for j in range(X+1)]


    
    for i in range(X+1):
        for j in range(Y+1):
            if i == 0 and j > 0:
                dp[i][j] = min(dp[i][j-1]+B, dp[i][j-1]+2*C)
            elif i > 0 and j == 0:
                dp[i][j] = min(dp[i-1][j]+A, dp[i-1][j]+2*C)
            elif i > 0 and j > 0:
                dp[i][j] = min(dp[i-1][j]+A, dp[i-1][j]+2*C, dp[i][j-1]+B, dp[i][j-1]+2*C, dp[i-1][j-1]+2*C)
    
    #for i  in range(X+1):
        #print(dp[i])
        
    print(dp[-1][-1])
                




if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

price = 5000 * 100000 * 2

for a in range(X+1):
    for b in range(Y+1):
        for c in range(min([2*(X-a), 2*(Y-b)]), X + Y + 1):
            if X <= a + c // 2 and Y <= b + c // 2:
                if price > A*a+B*b+C*c:
                    price = A*a+B*b+C*c

print(price)

Submission status: Time Limit Exceeded

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

mincost = 10000000000

for a in range(X + 1):
    for b in range(Y + 1):
        c = max([(X - a) * 2, (Y - b) * 2])
        cost = a * A + b * B + c * C
        if (cost < mincost):
            mincost = cost

print(mincost)

Submission status: Time Limit Exceeded

Solution code:
a, b, c, x, y= map(int, input().split())
# a, b, c, x, y = 1500, 2000, 1600, 3, 2

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

print(min(price))

Submission status: Time Limit Exceeded

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

price_min = float('inf')

for ib in range(Y+1):
    price_min_b = float('inf')
    for ia in range(X+1):
        ic = max(X-ia, Y-ib) * 2
        price = A*ia+B*ib+C*ic
        # print(ia, ib, ic, price)
        if price < price_min_b:
            price_min_b = price
        elif price > price_min_b:
            break
    if price_min_b < price_min:
        price_min = price_min_b
    elif price_min_b > price_min:
        break

print(price_min)

Submission status: Time Limit Exceeded

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

price_min = float('inf')

for ia in range(X+1):
    price_min_a = float('inf')
    for ib in range(Y+1):
        ic = max(X-ia, Y-ib) * 2
        price = A*ia+B*ib+C*ic
        # print(ia, ib, ic, price)
        if price < price_min_a:
            price_min_a = price
        elif price > price_min_a:
            break
    if price_min_a < price_min:
        price_min = price_min_a
    elif price_min_a > price_min:
        break

print(price_min)

Submission status: Time Limit Exceeded

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

num = int(a * x + b * y)
count = 0
for i in range(x + 1):
	for j in range(y + 1):
		k = 0
		m = d - 2 * i
		n = e - 2 * j
		if m >= n:
			k = m
		else:
			k = n
		count = int(i * a + j * b + k * c)
		if num > count:
			num = count

print(num)

Submission status: Accepted

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

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

Submission status: Accepted

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

res = a*x + b*y
for i in range(1, max(x, y)+1):
    ab = i*2
    cand = ab*c + a*max(0, x-i) + b*max(0, y-i)

    res = min(res, cand)

print(res)

Submission status: Accepted

Solution code:
a,b,c,x,y=map(int,input().split())
d= a*x+b*y
e= 2*c*x+b*max(0,y-x) #yが多い
f= 2*c*y+a*max(0,x-y) #xが多い
print(min(d,e,f))

Submission status: Accepted

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

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(c*2*min(x,y)+min(max(a*(x-y),b*(y-x)),c*2*abs(x-y)))

Submission status: Accepted

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

if A+B >= 2*C:
    planA = 2*C*max(X,Y)
    if X < Y:
        planB = 2*C*X + B * abs(X-Y)
    elif X > Y:
        planB = 2*C*Y + A * abs(X-Y)
    else:
        planB = planA
    
    ans = min(planA,planB)
else:
    ans = A*X + B*Y

print(ans)

Submission status: Accepted

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

mincost = a*x+b*y
for z in range(max(x,y)+1):
    x_ = max(0, x-z)
    y_ = max(0, y-z)
    cost = 2*c*z + a*x_ + b*y_
    mincost = min(mincost, cost)

print(mincost)

Submission status: Accepted

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

# set x >= y
if x < y: 
    x,y = y,x
    a,b = b,a

price_1 = a*x + b*y
price_2 = a*(x-y) + 2*c*y
price_3 = 2*c*x

print(min(price_1, price_2, price_3))

Submission status: Accepted

Solution code:


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

ans = 0

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

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

if ab_total < ans:
    print(ab_total)
else:
    print(ans)

Submission status: Accepted

Solution code:
A, B, C, X, Y = map(int, input().split())
ans = 2*(5000*10**5)
for Z in range(10**5+1):
    total = A*max(X-Z, 0)+B*max(Y-Z, 0)+2*C*Z
    ans = min(total,ans)
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:
    if X <= Y:
        print(min(2*C*Y, 2*C*X+B*(Y-X)))
    else:
        print(min(2*C*X, 2*C*Y+A*(X-Y)))

Submission status: Accepted

Solution code:
# coding:UTF-8
import sys
from math import factorial

MOD = 10 ** 9 + 7
INF = float('inf')

A, B, C, X, Y = list(map(int, input().split()))     # スペース区切り連続数字

mcost = INF

cnum = max(X, Y)
for i in range(cnum+1):
    anum = max(0, (X - i))
    bnum = max(0, (Y - i))
    cost = A * anum + B * bnum + C * i * 2
    mcost = min(mcost, cost)

print("{}".format(mcost))

Submission status: Accepted

Solution code:
import math
from math import gcd,pi,sqrt
INF = float("inf")
MOD = 10**9 + 7

import sys
sys.setrecursionlimit(10**6)
import itertools
import bisect
from collections import Counter,deque
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]


def main():
    A,B,C,X,Y = i_map()

    Z = max(X,Y)

    ans = INF
    C *= 2

    for i in range(0,Z+1):
        trial = i*C
        At = X - i
        Bt = Y - i
        if At > 0:
            trial += At*A
        if Bt > 0:
            trial += Bt*B
        ans = min(ans, trial)
    print(ans)

  
  
 
  
if __name__=="__main__":
    main()

Submission status: Accepted

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

ans = float("inf")
for c in range(200_001):
    cost = c * C
    cost += A * max(0, X - c // 2)
    cost += B * max(0, Y - c // 2)
    ans = min(ans, cost)
print(ans)

Submission status: Accepted

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

# AB ピザを買わない場合
pay1 = X*A + Y*B
# A ピザ を AB ピザで作る場合
pay2 = 10**10
if Y >= X:
    pay2 = C*2*X + B*(Y-X)
# B ピザを AB ピザで作る場合
pay3 = 10**10
if X >= Y:
    pay3 = A*(X-Y) + C*2*Y
# AB ピザで全部作る場合
pay4 = C*max(X,Y)*2
print(min(pay1,pay2,pay3,pay4))

Submission status: Accepted

Solution code:
import math

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

ans = A * X + B * Y

if (A + B) / 2 < C:
    pass
else:
    for i in range(max(X * 2, Y * 2)+1):
        j = max(0, X - int(i / 2))
        k = max(0, Y - int(i / 2))

        ans = min(ans, i * C + j * A + k * B)

print(ans)

Submission status: Accepted

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

min1 = 10**10
for z in range(0,200001,2):
    x = max(0,X-z//2)
    y = max(0,Y-z//2)
    min1 = min(min1,a*x + b*y + c*z)

print(min1)

Submission status: Accepted

Solution code:
a,b,c,x,y = map (int,input().split())
max_xy = max(x,y)
count_x=0
count_y=0
p=0
p_min = c*2*max_xy

for i in range(0,max_xy+1):
    #c
    x_last = x-i
    y_last = y-i
    if x_last <0 : x_last=0
    if y_last <0 : y_last=0
    p = c*2*i + a*(x_last) + b*(y_last)
    p_min = min(p_min,p)
print(p_min)

Submission status: Accepted

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

piza_min = min(x,y)

plan1 = c*piza_min*2 + a*(x-piza_min) + b*(y-piza_min)
plan2 = a*x + b*y
plan3 = c*max(x,y)*2

print(min(plan1,plan2,plan3))

Submission status: Accepted

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

ans = [a * x + b * y]

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

print(min(ans))

Submission status: Accepted

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

ans = 10**18
for k in range(2*10**5+1):
    if k%2 != 0:
        continue
    i = max(x-k//2, 0)
    j = max(y-k//2, 0)
    temp = a*i+b*j+c*k
    ans = min(ans, temp)
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:
  if x < y:
    if b > 2*c:
      print(y*2*c)
    else:
      print(x*2*c + (y-x)*b)
  else:
    if a > 2*c:
      print(x*2*c)
    else:
      print(y*2*c + (x-y)*a)

Submission status: Accepted

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

print(cost)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline

def main():
    a,b,c,x,y = map(int,input().split())
    ans1=99999999999999999999999999
    if a+b>2*c:
        if x > y:
            ans1=2*c*y+a*(x-y)
        elif y > x:
            ans1=2*c*x+b*(y-x)
    ans2=c*2*max(x,y)
    ans3=a*x+b*y
    print(min(ans1,ans2,ans3))

if __name__=="__main__":
    main()

Submission status: Accepted

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

print(res)

Submission status: Accepted

Solution code:
a_price,b_price,ab_price,num_a,num_b = map(int, input().split())
total = 0

if a_price + b_price < 2 * ab_price:
	total = a_price * num_a + b_price * num_b

elif a_price + b_price >= 2 * ab_price:
	if num_a >= num_b:
		if a_price > ab_price * 2:
			total = ab_price * 2 * num_a
		else:
			total = ab_price * 2 * num_b + a_price * (num_a - num_b)
	else:
		if b_price > ab_price * 2:
			total = ab_price * 2 * num_b
		else:
			total = ab_price * 2 * num_a + b_price * (num_b - num_a)

print(total)

Submission status: Accepted

Solution code:
from sys import stdin,stdout
def INPUT():return list(int(i) for i in stdin.readline().split())
def inp():return stdin.readline()
def out(x):return stdout.write(x)
import math
import random
J=998244353
from collections import deque
########################################################
a,b,c,x,y=INPUT()
#cost of 1 pi is a+b or 2*c
if 2*c<(a+b):
    cost=2*c*min(x,y)
    if x>y:
        r=x-y
        if 2*c>a:
            cost+=r*a
        else:
            cost+=r*(2*c)
        print(cost)
    else:
        r=y-x
        if 2*c>b:
            cost+=r*b
        else:
            cost+=r*(2*c)
        print(cost)
else:
    print(x*a+y*b)

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]
s_1, s_2, s_3 = 0, 0, 0

s_1 = A*X + B*Y

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

print(min([s_1, s_2, s_3]))

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

import math
saishou = math.inf

temp = 0

for i in range (0, X+1):
	temp = A*i+C*2*(X-i)
	if X-i < Y:
		if 2*C <= B:
			temp+=2*C*(Y-(X-i))
		else:
			temp+=B*(Y-(X-i))
	if saishou > temp:
		saishou = temp
                      
print(saishou)

Submission status: Accepted

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

Submission status: Accepted

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

# C for both A and B
cost = max(X, Y) * C * 2
ans = min(ans, cost)

if X > Y:
    cost = Y * C * 2
    cost1 = cost + (X - Y) * A
    cost2 = cost + (X - Y) * C * 2
    cost = min(cost1, cost2)
    ans = min(ans, cost)
else:
    cost = X * C * 2
    cost1 = cost + (Y - X) * B
    cost2 = cost + (Y - X) * C * 2
    cost = min(cost1, cost2)
    ans = min(ans, cost)

cost = A * X + B * Y
ans = min(ans, cost)

print(ans)

Submission status: Accepted

Solution code:
# import itertools
# import math
# from functools import reduce
# import sys
# sys.setrecursionlimit(500*500)
# import numpy as np
# import heapq
# from collections import deque

# N = int(input())
# S = input()
# n, *a = map(int, open(0))
A, B, C, X, Y = map(int, input().split())
# A = list(map(int, input().split()))
# B = list(map(int, input().split()))
# tree = [[] for _ in range(N + 1)]
# B_C = [list(map(int,input().split())) for _ in range(M)]
# S = input()

# B_C = sorted(B_C, reverse=True, key=lambda x:x[1])
# all_cases = list(itertools.permutations(P))
# a = list(itertools.combinations_with_replacement(range(1, M + 1), N))
# itertools.product((0,1), repeat=n)

# A = np.array(A)
# cum_A = np.cumsum(A)
# cum_A = np.insert(cum_A, 0, 0)

# def dfs(tree, s):
#     for l in tree[s]:
#         if depth[l[0]] == -1:
#             depth[l[0]] = depth[s] + l[1]
#             dfs(tree, l[0])
# dfs(tree, 1)

# def factorization(n):
#     arr = []
#     temp = n
#     for i in range(2, int(-(-n**0.5//1))+1):
#         if temp%i==0:
#             cnt=0
#             while temp%i==0:
#                 cnt+=1
#                 temp //= i
#             arr.append([i, cnt])
#     if temp!=1:
#         arr.append([temp, 1])
#     if arr==[]:
#         arr.append([n, 1])
#     return arr

# def gcd_list(numbers):
#     return reduce(math.gcd, numbers)

# if gcd_list(A) > 1:
#     print("not coprime")
#     exit()

# 高速素因数分解準備
#MAXN = 10**6+10
#sieve = [i for i in range(MAXN+1)]
#p = 2
#while p*p <= MAXN:
#    if sieve[p] == p:
#        for q in range(2*p, MAXN+1, p):
#            if sieve[q] == q:
#                sieve[q] = p
#    p += 1

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

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

Submission status: Accepted

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

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

ans = 10000 * 10**5
for z in range(10**5+1):
    x = max(X-z, 0)
    y = max(Y-z, 0)
    yen = A*x + B*y + 2*C*z
    if ans > yen:
        ans = yen

print(ans)

Submission status: Accepted

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