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:
# Problem: https://atcoder.jp/contests/arc096/tasks/arc096_a
# Python 2nd Try

import sys
# from collections import defaultdict
# import heapq,copy
import pprint as pp
# from collections import deque
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]


# Const
MAXSIZE = ( 1 << 31 ) -1
MINSIZE = -( 1 << 31) + 1
MAXSHEET = 10**5

def solver(a_price, b_price, ab_price, x_sheet , y_sheet):
    result = MAXSHEET*a_price+MAXSHEET*b_price
    for j in range(0, 2*MAXSHEET+1, 2):
        a_buy_sheet = max(x_sheet-j//2,0)
        b_buy_sheet = max(y_sheet - j//2, 0 )
        total = ( a_buy_sheet*a_price + b_buy_sheet*b_price +
                                         j*ab_price )
#       print("total={}".format(total))
        check = ( total < result )
        if check:
#           print("値は{}に".format(total))
            result = total
    return result


if __name__ == "__main__":
    a_price, b_price, ab_price, x_sheet , y_sheet = MI()
    print("{}".format(solver(a_price, b_price,
                             ab_price, x_sheet, y_sheet)))

Submission status: Accepted

Solution code:
def main():
	A,B,C,X,Y = map(int,input().split())
	ans = A*X + B*Y
	for i in range(1,min(X,Y)+1):
		ans = min(ans,ans-A-B+2*C)
	if Y < X:
		for i in range(Y+1,X+1):
			ans = min(ans, ans - A + C * 2)
	else:
		for i in range(X+1, Y+1):
			ans = min(ans, ans - B + C * 2)
	print(ans)
main()

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*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())
ans=0


if A+B > C*2:
    Z = min(X,Y)
    ans += 2*C*Z
    X -= Z
    Y -= Z
a = min(A,2*C)
b = min(B,2*C)

ans += a*X
ans += b*Y

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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:
# -*- coding: utf-8 -*-

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

# AB only
yen1 = max(X,Y) * 2 * C

# A + AB
yen2 = (max(X-Y, 0) * A) + (Y * 2 * C)

# AB + B
yen3 = (X * 2 * C) + (max(Y-X, 0) * B)

# A + B
yen4 = X * A + Y * B

ans = min(yen1, yen2, yen3, yen4)
print(ans)

Submission status: Accepted

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

max = max(x,y)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# vim: fileencoding=utf-8


def main():
    a, b, c, x, y = map(int, input().split())
    ans = float("inf")
    for i in range(0, max(x, y) * 2 + 1, 2):
        p = x - i // 2
        p = max(0, p)
        q = y - i // 2
        q = max(0, q)
        sum = a * p + b * q + c * i
        if ans > sum:
            ans = sum
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

INF = float("inf")
b = 0
for a in range(X + 1):
    sum = A * a
    ab_a = (X - a) * 2
    ab_b = ab_a
    sum += C * ab_a
    if ab_b / 2 < Y:
        if B < C * 2:
            b = round(Y - ab_b / 2)
            sum += B * b
        else:
            sum += C * int(Y - (ab_b / 2)) * 2
    if sum < INF:
        INF = sum
print(INF)

Submission status: Accepted

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

AB_flag = C * 2 <= A + B

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

print(total)

Submission status: Accepted

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

#cのセット数の最大値
cmax=max(x,y)

t_list=[]

#cを何セット買うか
for i in range(cmax+1):
   total=i*2*c+max(0,x-i)*a+max(0,y-i)*b
   t_list.append(total)
    
print(min(t_list))

Submission status: Accepted

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

#cのセット数の最大値
cmax=max(x,y)

t_list=[]

#cを何セット買うか
for i in range(cmax+1):
    if x>=i and y>=i:
        total=c*2*i+a*(x-i)+b*(y-i)
        
    elif x>=i and y<i:
        total=c*2*i+a*(x-i)
        
    else:
        total=c*2*i+b*(y-i)
        
    t_list.append(total)
    
print(min(t_list))

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
ins = lambda: input().rstrip()
ini = lambda: int(input().rstrip())
inm = lambda: map(int, input().split())
inl = lambda: list(map(int, input().split()))
out = lambda x: print('\n'.join(map(str, x)))

a, b, c, x, y = inm()
first = a*x + b*y
second = min(x, y) * c * 2 + abs(x-y) * (a if x > y else b)
third = max(x, y) * c * 2
print(min(first, second, third))

Submission status: Accepted

Solution code:
a, b, c, x, y = map(int, input().split())
ans = 0
flag = 0
if a + b < 2*c:
    ans = a*x + b*y
elif a + b >= 2*c:
    if x > y:
        if a > 2*c:
            ans = 2*c*x
            flag = 1
        elif a <= 2*c:
            ans = 2*c*y + a*(x-y)
            flag = 2
    elif x < y:
        if b > 2*c:
            ans = 2*c*y
            flag  = 3
        elif b <= 2*c:
            ans = 2*c*x + b*(y-x)
            flag = 4
    elif x == y :
        ans = 2*c*x
        flag = 5

# print(flag)
print(ans)

Submission status: Accepted

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

num_A = 0
num_B = 0
num_AB = 0
if A + B <= 2 * C:
    num_A = X
    num_B = Y
else: # A + B > 2 * C
    Z = min(X, Y)
    X = X - Z
    Y = Y - Z
    num_AB = 2 * Z

    if A >= 2 * C:
        num_AB += 2 * X
    else: # A < 2 * C

        num_A = X
    if B >= 2 * C:
        num_AB += 2 * Y
    else: # B < 2 * C
        num_B = Y

ans = A * num_A + B * num_B + C * num_AB
print(ans)

Submission status: Accepted

Solution code:

A, B, C, X, Y = map(int, input().split())
ans = A*X+B*Y
# ABセットを全探索する
for i in range(1, max(X,Y)+1):
    # i > Xであれば買い増す必要はないが、i < Xであれば必要なため
    ans = min(ans, A*max(X-i,0)+B*max(Y-i,0)+C*2*i)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#
# arc096 c
#
import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """1500 2000 1600 3 2"""
        output = """7900"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """1500 2000 1900 3 2"""
        output = """8500"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """1500 2000 500 90000 100000"""
        output = """100000000"""
        self.assertIO(input, output)


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

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


if __name__ == "__main__":
    # unittest.main()
    resolve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]
#a = [input() for _ in range(n)]

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

ans = []

c_max_num = max(x,y)*2

for c_num in range(c_max_num+1):
    a_num = max(0, x - c_num//2)
    b_num = max(0, y - c_num//2)

    tmp = a*a_num + b*b_num + c*c_num
    ans.append(tmp)


print(min(ans))

Submission status: Accepted

Solution code:
def main():
	A, B, C, X, Y = map(int, input().split())
	lst = [0] * (10 ** 5 + 1)

	for i in range(10 ** 5 + 1):
		lst[i] = 2 * C * i + max(X - i, 0) * A + max(Y - i, 0) * B

	print(min(lst))


  
if __name__ == "__main__":
  	main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:

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

res = 10**10
for i in range(0, max(x, y)*2+2, 2):
    a_piza = max(0, x - (i // 2))
    b_piza = max(0, y - (i // 2))
    res = min(res, a_piza*a + b_piza*b + i*c)

print(res)

Submission status: Accepted

Solution code:
# Problem: https://atcoder.jp/contests/arc096/tasks/arc096_a
# Python 1st Try

import sys
# from collections import defaultdict
# import heapq,copy
import pprint as pp
# from collections import deque
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]


# CONST
MAXSIZE = ( 1 << 31 ) -1
MINSIZE = -( 1 << 31) + 1

def solver(a_price, b_price, c_price, target_x, target_y):
    result = MAXSIZE
    for mix_i in range(0, 2 * 10**5+1, +1):
        a_i = target_x - mix_i//2
        b_i = target_y - mix_i//2
        totalPrice = max(a_i, 0) * a_price + max(b_i,0) * b_price + mix_i * c_price
        if totalPrice < result:
            # print("A={},B={},C={} -> total = {}".format(a_i, b_i, mix_i, totalPrice))
            result = totalPrice
    return result


if __name__ == "__main__":
    A, B, C, X, Y = MI()
    print("{}".format(solver(A, B, C, X, Y)))

Submission status: Accepted

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

sum = 0

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

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

Submission status: Accepted

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

#AとBをそのまま買う
ans1 = A * X + B * Y

#ABを可能な限り買って、残りのAかBを買う
if X > Y :
  ans2 = C * Y * 2 + A * (X - Y) 
else:
  ans2 = C * X * 2 + B * (Y - X) 
#とにかくABだけ買う
ans3 = C * max(X, Y) * 2

print(min(ans1,ans2,ans3))

Submission status: Accepted

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

print(sm)

Submission status: Accepted

Solution code:
a,b,c,x,y=map(int,input().split())
cost=min((a+b),(c*2))*min(x,y)
remain= a if x > y else b
cost+=min(remain,(c*2))*abs(x-y)
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)
elif X==Y or (X>Y and A>=2*C) or (X<Y and B>=2*C):
    print(2*max([X,Y])*C)
elif X>Y and A<2*C:
    print(2*Y*C+A*(X-Y))
elif X<Y and B<2*C:
    print(2*X*C+B*(Y-X))

Submission status: Accepted

Solution code:
mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
def main():
    a, b, c, x, y = map(int, input().split())
    r = a * x + b * y
    for i1 in range(1, min(x, y) + 1):
        r1 = r - a - b + c * 2
        r = min(r, r1)
    if x > y:
        for j1 in range(y + 1, x + 1):
            r1 = r - a + c * 2
            r = min(r, r1)
    else:
        for j1 in range(x + 1, y + 1):
            r1 = r - b + c * 2
            r = min(r, r1)
    print(r)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
def main():
    a, b, c, x, y = map(int, input().split())
    p1 = a * x + b * y
    p2 = max(x, y) * 2 * c
    p3 = min(x, y) * 2 * c + ((x - y) * a if x > y else (y - x) * b)
    r = min(p1, p2, p3)
    print(r)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

cc = c * 2 * max(x, y)
print(min(ab, abc, cc))

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

ans = A * X + B * Y

t = max(X, Y)

for i in range(2, (t+1)*2, 2):
    if (X - i//2) < 0:
        ans = min(ans, C * i + B * (Y - i//2))
    elif (Y - i//2) < 0:
        ans = min(ans, C * i + A * (X - i//2))
    else:
        ans = min(ans, C * i + A * (X - i//2) + B * (Y - i//2))

print(ans)

Submission status: Accepted

Solution code:
a, b, c, x, y = map(int,input().split())
c = 2 * c
money = 0
apizza = 0
bpizza = 0
ans = 0
for i in range(max(x,y) + 1):
    apizza = x - i
    if apizza < 0:
        apizza = 0
    bpizza = y - i
    if bpizza < 0:
        bpizza = 0
    ans = apizza * a + bpizza * b + c * i
    if money > ans or i == 0:
        money = ans
print(money)

Submission status: Accepted

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

sum_list=[]


max_c=max(x,y)

#ABセットをi組頼む
for i in range(max_c+1):
    
    #Cのみ
    if i>=x and i>=y:
        sum=2*c*i
        
    #CとA
    elif i<x and i>=y:
        sum=2*c*i+a*(x-i)
    
    #CとB   
    elif i>=x and i<y:
        sum=2*c*i+b*(y-i)
    
    #CとAとB
    else:
        sum=2*c*i+a*(x-i)+b*(y-i)
        
    sum_list.append(sum)
    
    
print(min(sum_list))

Submission status: Accepted

Solution code:
# n, m, l = map(int, input().split())

# list_n = list(map(int, input().split()))

# n = input()
# list = [input() for i in range(N)

# list = [[i for i in range(N)] for _ in range(M)]

import sys
input = sys.stdin.readline

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

ans = 0
if Y < X:
    Y, X = X, Y
    B, A = A, B

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

print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
a, b, c, x, y = map(int, input().split())

ab = a * x + b * y

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

if x >= y:
    cc = c * 2 * x
else:
    cc = c * 2 * y


print(min(ab, cab,cc))

Submission status: Accepted

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

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

# A, Bだけでいく
case1 = A * X + B * Y

# AをABでつくってBがたりなかったらうめる
case2 = 2*C * X + B * max(Y - X, 0)

# BをABでつくってBがたりなかったらうめる
case3 = 2*C * Y + A * max(X - Y, 0)

# 全部AB
case4 = 2*C * max(X, Y)

# print(case1, case2, case3, case4)
print(min(case1, case2, case3, case4))

Submission status: Accepted

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

ans = 0
if a + b >= 2*c:
  if x >= y:
    ans = ans + 2*c*y
    z = x-y
    ans += min(a*z, 2*c*z)
  else:
    ans = ans + 2*c*x
    z = y-x
    ans += min(b*z, 2*c*z)
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 X>Y:
    r=Y
else:
    r=X
if A+B>2*C:
    ans+=2*C*r
else:
    ans+=(A+B)*r
X-=r
Y-=r

if X!=0:
    if A>2*C:
        ans+=2*C*X
    else:
        ans+=A*X
else:
    if B>2*C:
        ans+=2*C*Y
    else:
        ans+=B*Y

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b,c,x,y = list(map(int,input().split()))
m = a*x + b*y
n = max(x, y) * 2*c
d = {x: b, y: a}
v = 2*c*min(x, y) + d[min(x, y)]*abs(x-y)
print(min(m, n, v))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A, B, C, X, Y = map(int, input().split())
D = {X:B, Y:A}
P = [A*X+B*Y, C*2*min(X, Y)+D[min(X,Y)]*abs(X-Y), C*2*max(X, Y)]

print(min(P))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

budget = A* X+ B* Y
i = 1

while True:
  if(max(A* (X- i), 0)+ max(B* (Y- i), 0)+ C* 2* i< budget):
    budget = max(A* (X- i), 0)+ max(B* (Y- i), 0)+ C* 2* i
  else:
    break
  i+= 1

print(budget)

Submission status: Accepted

Solution code:
a, b, c, x, y = map(int, open(0).read().split())
c *= 2
xy = min(x, y)
res = xy * min(a + b, c) + (x - xy) * min(a, c) + (y - xy) * min(b, c)
print(res)

Submission status: Accepted

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

    judge = 0
    price = 0
#同じ枚数なのは何枚か数える
    same_num = X - Y
    if same_num < 0:
        judge = -1
        same_num = -same_num
    elif same_num > 0:
        judge = 1

    if 2*C > (A + B):
        price += (max(X,Y)-same_num)*(A + B)
    elif 2*C < (A + B):
        price += (max(X,Y)-same_num)*C*2
    elif 2*C == (A + B):
        price += (max(X,Y)-same_num)*C*2

    if judge == 1:
        if 2*C > A:
            price += A*same_num
        elif 2*C < A:
            price += 2*C*same_num
        elif 2*C == A:
            price += A*same_num

    elif judge == -1:
        if 2*C > B:
            price += B*same_num
        elif 2*C < B:
            price += 2*C*same_num
        elif 2*C == B:
            price += B*same_num
    return price

print(main())

Submission status: Accepted

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

p1 = a*x + b*y
p2 = 2*c*max(x, y)
p3 = 2*c*y + a*(x-y) if x > y else 2*c*x + b*(y-x)

print(min(p1, p2, p3))

Submission status: Accepted

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

if A+B >= 2*C:
    priceA = 2*C*max(X,Y)
    priceB = 2*C*min(X,Y)
    if X > Y:
        priceB += A * (X-Y)
    elif Y > X:
        priceB += B * (Y-X)

    print(min(priceA,priceB))

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

Submission status: Accepted

Solution code:
a, b, c, x, y = map(int, input().split())
p1 = a * x + b * y
p2 = 2 * c * (min(x, y))
p3 = 2 * c * (max(x, y))
if x > y:
    p2 += a * (x - y)
elif x < y:
    p2 += b * (y - x)

print(min(p1, p2, p3))

Submission status: Accepted

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

min_sum = A*X + B*Y
for c in range(0, 100000+1):
    sum = 2*C*c
    if X - c > 0:
        sum += A * (X - c)
    if Y - c > 0:
        sum += B * (Y - c)
    if sum < min_sum:
        min_sum = sum
print(min_sum)

Submission status: Accepted

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

res = a*x + b*y # 条件を満たす買い方のうちABピザの枚数(*2)を全探索する。ABピザを一切買わない場合を一旦答えにする（これを大きい値にして、for ループを0からにしてもよい）
for i in range(1, max(x, y)+1): # 全部ABピザでまかなう時は x,yの内多い方分買うことになる
    ab = i*2 # ABピザを買う枚数奇数枚買うことはないので2倍
    cand = ab*c + a*max(0, x-i) + b*max(0, y-i) # i枚分はABピザになるので-i 負の値にはならない（あまりになる）ので0とのmaxをとる

    res = min(res, cand) # 候補との最小値を保持

print(res)

Submission status: Accepted

Solution code:
A, B, C, X, Y = map(int, input().split())
cost = A*X + B*Y
new_cost = cost
plus = 0
for i in range(1, max(X, Y)+1):
  if i <= min(X, Y):
    plus = - A - B + 2*C
  else:
    plus = -A + 2*C if X > Y else -B + 2*C
  if plus < 0:
    new_cost += plus
  else:
    break
print(new_cost)

Submission status: Accepted

Solution code:
a,b,c,x,y=list(map(int,input().split()))
temp=0
ans=float("Inf")
import math
while temp<=max(x,y)*2:
  xt=math.ceil(x-0.5*temp)
  yt=math.ceil(y-0.5*temp)
  ans=min(ans,max(0,xt)*a+max(0,yt)*b+temp*c)
  temp=temp+1
print(ans)

Submission status: Accepted

Solution code:
import math

__DEUBG__ = 0

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

minimum = a * x + b * y

if x > y:
    for i in range(x+1):
        N_a = i
        N_c = 2 * (x - i)
        if (y-N_c/2) < 0:
            N_b = 0
        else:
            N_b = y - int(N_c/2)
        tmp = a * N_a + b * N_b + c * N_c
        if tmp < minimum:
            minimum = tmp
            if __DEUBG__:
                print(tmp, N_a, N_b, N_c)
else:
    for i in range(y+1):
        N_b = i
        N_c = 2 * (y - i)
        if (x-N_c/2) < 0:
            N_a = 0
        else:
            N_a = x - int(N_c/2)
        tmp = a * N_a + b * N_b + c * N_c
        if tmp < minimum:
            minimum = tmp
            if __DEUBG__:
                print(tmp, N_a, N_b, N_c)

print(minimum)

Submission status: Accepted

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

x = y = z = 0

if 2 * C >= A + B:
    x = min(X, Y)
    y = x
else:
    z = min(X, Y) * 2

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

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

print(A*x + B*y + C*z)

Submission status: Accepted

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

if x<y:
    x,y=y,x
    a,b=b,a

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
"""
O(1)解法
以下の3つから一番安いものを選ぶ
1. AピザとBピザをそれぞれ必要数買う場合
2. ABピザを必要数の多いピザ基準で買う場合 (2倍必要になることを忘れない)
3. ABピザを必要数の少ないピザ基準で買い、不足分のピザを買い足す場合
"""
A, B, C, X, Y = map(int, input().split())
# Aピザの必要数がBピザよりも多くなるように、必要数と値段を入れ替える
if X < Y:
    X, Y = Y, X
    A, B = B, A
p1 = A * X + B * Y  # 1
p2 = 2 * C * X  # 2
p3 = 2 * C * Y + (X - Y) * A  # 3
print(min(p1, p2, p3))

Submission status: Accepted

Solution code:
A, B, C, X, Y = map(int, input().split())
m_value = float('inf')
for ab in range(max(X, Y) + 1):
    ab2 = 2 * ab
    a = X - ab
    b = Y - ab
    tmp = C * ab2
    if a > 0:
        tmp += a * A
    if b > 0:
        tmp += b * B
    m_value = min(m_value, tmp)
print(m_value)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

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

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

Submission status: Accepted

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

hantei=0

#初期値
result=A*X+B*Y

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

    result=int(min(result,hantei))

print(result)

Submission status: Accepted

Solution code:
a_price, b_price, ab_price, a_num, b_num = map(int, input().split())
if a_num >= b_num:
  amari_price = a_price
else:
  amari_price = b_price
min_price = float('inf')
price1 = a_price*a_num+b_price*b_num
price2 = min(a_num,b_num)*ab_price*2 + abs(a_num-b_num)*amari_price
price3 = max(a_num,b_num)*ab_price*2
print(min(price1,price2,price3))

Submission status: Accepted

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

price = a * x + b * y

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

    else:
        price = min(2 * x * c + (y - x) * b,  2 * y * c)

print(price)

Submission status: Accepted

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

if (a + b) // 2 >= c:
    min_price = 'c'
else:
    min_price = 'other'

if min_price == 'c':
    if x >= y:
        price = min(2 * x * c, 2 * y * c + (x - y) * a)

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

print(price)

Submission status: Accepted

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

    minPrice = 10**20

    for i in range(2 * (x + y) + 1):
        pizzaC = i * c
        pizzaB = max(0, y - i // 2) * b
        pizzaA = max(0, x - i // 2) * a

        price = pizzaA + pizzaB + pizzaC
        
        if price < minPrice:
            minPrice = price

    print(minPrice)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
A, B, C, X, Y = list(map(int, input().split()))
for num_c in range(0, 2 * max(X, Y) + 1, 2):
    num_a = X - num_c // 2 if X - num_c // 2 > 0 else 0
    num_b = Y - num_c // 2 if Y - num_c // 2 > 0 else 0
    if num_c == 0:
        min_money = A * num_a + B * num_b
    else:
        if (A * num_a + B * num_b + C * num_c) < min_money:
            min_money = A * num_a + B * num_b + C * num_c
print(min_money)

Submission status: Accepted

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

INF = (10**5)*a + (10**5)*b + 1
ans = INF

c = 2*c

m = max(x, y)

for num in range(m+1):
    num_x = max(0, x - num)
    num_y = max(0, y - num)
    ans = min(num_x*a + num_y*b + num*c, ans)

print(ans)

Submission status: Accepted

Solution code:
def resolve():
    # 整数 1 つ
    # n = int(input())
    # 整数複数個
    a, b, c, x, y = map(int, input().split())
    # 整数 N 個 (改行区切り)
    # N = [int(input()) for i in range(N)]
    # 整数 N 個 (スペース区切り)
    # N = list(map(int, input().split()))
    # 整数 (縦 H 横 W の行列)
    # A = [list(map(int, input().split())) for i in range(H)]

    paymin = max(a, b, c) * (x + y) *2
    for ab in range(max(x, y)+1):
        if paymin > (2 * ab * c) + (max((x - ab), 0) * a) + (max((y - ab), 0) * b):
            paymin = (2 * ab * c) + (max((x - ab), 0) * a) + (max((y - ab), 0) * b)

    print(paymin)
resolve()

Submission status: Accepted

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

m = 5000 * 200001
for k in range(200001):
    i = max(0, X - int(k / 2))
    j = max(0, Y - int(k / 2))
    m = min(m, A * i + B * j + C * k)
print(m)