Problem:


Score : 300 points

Problem Statement

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

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

Constraints

1 ≤ A, B, C ≤ 5000

1 ≤ X, Y ≤ 10^5

All values in input are integers.

Input

Input is given from Standard Input in the following format:

A B C X Y

Output

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

Sample Input 1

1500 2000 1600 3 2

Sample Output 1

7900

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

Sample Input 2

1500 2000 1900 3 2

Sample Output 2

8500

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

Sample Input 3

1500 2000 500 90000 100000

Sample Output 3

100000000

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



Sample input:
1500 2000 1600 3 2


Sample output:
7900

Submission status: Accepted

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

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

Z = abs(X - Y)
D = A if X >= Y else B
if D > 2 * C:
    ans += 2 * C * Z
else:
    ans += Z * D

print(ans)

Submission status: Accepted

Solution code:
cost_a,cost_b,cost_ab,num_a,num_b = map(int,input().split())
if num_a > num_b:
  num_ab = num_b * 2
  need_a = num_a - (num_ab // 2)
  cost1 = need_a * cost_a + num_ab * cost_ab
  
  num_ab = num_a * 2
  cost3 = num_ab * cost_ab
  cost1 = min(cost1,cost3)
elif num_a < num_b:
  num_ab = num_a * 2
  need_b = num_b - (num_ab // 2)
  cost1 = need_b * cost_b + num_ab * cost_ab

  num_ab = num_b * 2
  cost3 = num_ab * cost_ab
  cost1 = min(cost1,cost3)
else:
  num_ab = num_b * 2  
  cost1 = num_ab * cost_ab

cost2 = cost_a * num_a + cost_b * num_b
ans = min(cost1,cost2)
print(ans)

Submission status: Accepted

Solution code:
a,b,c,x,y=map(int,input().split())
ans=10**18
for i in range(0,2*max(x,y)+2,2):
  X,Y=x,y
  X-=i//2
  Y-=i//2
  X=max(0,X)
  Y=max(0,Y)
  ans=min(ans,a*X+b*Y+c*i)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

ans = float("inf")
max_ab = max(x, y) * 2
# abピザをi(=2n)枚買うと想定
for i in range(0, max_ab+1, 2):
    rest_x = max(0, x - i//2)
    rest_y = max(0, y - i//2)
    cost = c*i + a*rest_x + b*rest_y
    ans = min(ans, cost)

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

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

if a+b<=c*2:
  while x>0 and y>0:
    ans+=a+b
    x-=1
    y-=1

else:
  if (c*2>a and c*2>b) or (c>=a and x>=y) or (c>=b and y>x):
    while x>0 and y>0:
      ans+=c*2
      x-=1
      y-=1
  else:
    while x>0 or y>0:
      ans1+=c*2
      x-=1
      y-=1
    print(ans1)
    sys.exit()

if x==0:
  while y>0:
    ans+=b
    y-=1

else:
  while x>0:
    ans+=a
    x-=1

print(ans)

Submission status: Accepted

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

TotalPrice = 2 * 5000 * 10**5
for i in range(max(X, Y) + 1):
    priceA = A * max(X - i, 0)
    priceB = B * max(Y - i, 0)
    priceC = 2 * C * i
    TotalPrice = min(TotalPrice, priceA + priceB + priceC)

print(TotalPrice)

Submission status: Accepted

Solution code:
import sys
import itertools
import math
from collections import deque
MAX_INT = int(10e15)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

p = [a * x + b * y, c * max(x, y) * 2]
if x != y:
    p.append(c * y * 2 + a * (x-y)) if x > y else p.append(c * x * 2 + b * (y-x))

print(min(p))

Submission status: Accepted

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

p = [a * x + b * y, c * max(x, y) * 2]
if x != y:
    if x > y:
        p.append(c * y * 2 + a * (x-y))
    else:
        p.append(c * x * 2 + b * (y-x))

print(min(p))

Submission status: Accepted

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

ans = float("inf")
for i in range(200000):
    tmp = 0
    tmp += c * i * 2
    if x - i>0:
        tmp += a *(x-i)
    if y - i>0:
        tmp += b *(y-i)
    ans = min(ans, tmp)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

print(ans)

Submission status: Accepted

Solution code:
A, B, C, X, Y = map(int, input().split())
faceAB = (A + B) / 2
sumPizza = 0

if faceAB <= C:
    ans = X * A + Y * B
else:
    def2 = 2 * C * max(X, Y)
    if X <= Y:
        tmp = 2 * C * min(X, Y) + ((Y - X) * B)
    else:
        tmp = 2 * C * min(X, Y) + ((X - Y) * A)
    ans = min(def2, tmp)
print(ans)

Submission status: Accepted

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

p2 = 0
for i in range(max(x, y)):
    ai = a * (x - i) if i < x else 0
    bi = b * (y - i) if i < y else 0
    abi = 2 * i * c
    p1 = ai + bi + abi

    ai1 = a * (x - i - 1) if i < x else 0
    bi1 = b * (y - i - 1) if i < y else 0
    abi1 = 2 * (i + 1) * c
    p2 = ai1 + bi1 + abi1
    if p1 < p2:
        print(p1)
        exit()

print(p2)

Submission status: Accepted

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

Submission status: Accepted

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

if a + b > c * 2:
    buf = min(x,y) * c * 2
    buf2 = max(x,y) * c * 2
    if x > y:
        tmp = buf + (x-y) * a
    else:
        tmp = buf + (y-x) * b
    ans = min(buf2,tmp)
else:
    ans = x * a + y * b

print(ans)

Submission status: Accepted

Solution code:
A, B, C, X, Y = map(int, input().split())
ans = 0
a = b = c = 0

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

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

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

print(ans)

Submission status: Accepted

Solution code:

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

def cal(cp):
    res=2*cp*c
    xx=x-cp
    yy=y-cp
    res+=a*max(0,xx)+b*max(0,yy)
    return res

ans=[cal(0),cal(x),cal(y),cal(x+y)]
print(min(ans))

Submission status: Accepted

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

for i in range(10**5+1):
  price=2*c*i+a*max(0,x-i)+b*max(0,y-i)
  li.append(price)
  
print(min(li))

Submission status: Accepted

Solution code:
a, b, c, x, y = map(int, input().split())
#a, b, c, x, y = 1500, 2000, 500, 90000, 100000
#na, nb, nc = x, y, 0
mx = 10**18
for i in range(0, max(x,y)*2+1):
  if i%2==1: continue
  total = max(a*(x-i//2), 0) + max(b*(y-i//2), 0) + c*i
  if total<mx:
    mx=total

print(mx)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(price)

Submission status: Accepted

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

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

print(price)

Submission status: Accepted

Solution code:
a,b,c,x,y=map(int,input().split())
ans1=a*x+b*y
ans2=0
ans3=max(x,y)*2*c

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

print(min(ans1,ans2,ans3))

Submission status: Accepted

Solution code:
import glob

# 問題ごとのディレクトリのトップからの相対パス
REL_PATH = 'ABC\\95\\C'

# テスト用ファイル置き場のトップ
TOP_PATH = 'C:\\AtCoder'


class Common:

    problem = []
    index = 0

    def __init__(self, rel_path):
        self.rel_path = rel_path

    def initialize(self, path):
        file = open(path)
        self.problem = file.readlines()
        self.index = 0
        return

    def input_data(self):
        try:
            IS_TEST
            self.index += 1
            return self.problem[self.index-1]

        except NameError:
            return input()

    def resolve(self):
        pass

    def exec_resolve(self):
        try:
            IS_TEST
            for path in glob.glob(TOP_PATH + '\\' + self.rel_path + '/*.txt'):
                print("Test: " + path)
                self.initialize(path)
                self.resolve()
                print("\n\n")
        except NameError:
            self.resolve()


class Solver(Common):

    def resolve(self):

        q = [int(i) for i in self.input_data().split()]
        A = q[0]
        B = q[1]
        C = q[2]
        X = q[3]
        Y = q[4]

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

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

        print(str(result))


solver = Solver(REL_PATH)
solver.exec_resolve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a, b, c, x, y = map(int, input().split())
ans = 10 ** 9
for cn in range(0, max(x, y) * 2 + 1, 2):
    may = max(0, x - cn // 2) * a + max(0, y - cn // 2) * b + cn * c
    ans = min(ans, may)
print(ans)

Submission status: Accepted

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

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

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

Submission status: Accepted

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

A, B, C, X, Y = map(int, input().split(' '))
set_price = min(A+B, C*2)
set_num = min(X, Y)

ans = set_price * set_num
if X > Y:
    ans += min(A, C*2) * (X-Y)
elif X < Y:
    ans += min(B, C*2) * (Y-X)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b,c,x,y=map(int,input().split())
buy_x=x
buy_y=y
buy_z=0
ans=a*buy_x+b*buy_y

for i in range(max(x,y)*2):
    if (a+b>c*2):
        if (buy_x>0 and buy_y>0):
            buy_x-=1
            buy_y-=1
            buy_z+=2
        elif (buy_x==0 and buy_y>0 and b>c*2):
            buy_y-=1
            buy_z+=2
        elif (buy_x>0 and buy_y==0 and a>c*2):
            buy_x-=1
            buy_z+=2
    else:
        break
        
print(buy_x*a+buy_y*b+buy_z*c)

Submission status: Accepted

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

def main():
    A, B, C, X, Y = map(int, input().split())
    ans = float("inf")
    for k in range(2 * max(X, Y) + 1):
        i = max(0, math.ceil(X - 0.5 * k))
        j = max(0, math.ceil(Y - 0.5 * k))
        total = A * i + B * j + C * k
        if ans > total:
            ans = total
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

# a,b,c=0,0,0
# min_nedan=5000*(X+Y)
# tmp_nedan=0
# for a in range(X+1):
#     for b in range(Y+1):
#         c = 2*max(X-a,Y-b)
#         tmp_nedan = a*A+b*B+c*C
#         if tmp_nedan < min_nedan:
#             min_nedan = tmp_nedan
#
# print(min_nedan)

min_nedan=5000*(X+Y)
tmp_nedan=0
if A+B > 2*C:
    tmp_nedan += 2*C*min(X,Y)
    if X > Y:
        if A > 2*C:
            tmp_nedan+=2*C*(X-Y)
        elif A <= 2*C:
            tmp_nedan+=A*(X-Y)
    elif X<= Y:
        if B > 2*C:
            tmp_nedan+=2*C*(Y-X)
        elif B <= 2*C:
            tmp_nedan+=B*(Y-X)
elif A+B <= 2*C:
    tmp_nedan += A*X+B*Y

print(tmp_nedan)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

ans = float("inf")
for i in range(0, max(2*x, 2*y)+1, 2):
    na = 0 if x-i//2 < 0 else x-i//2
    nb = 0 if y-i//2 < 0 else y-i//2
    ans = min(ans, c*i + a*na + b*nb)

print(ans)

Submission status: Accepted

Solution code:
a, b, c, x, y = map(int, input().split())
mini = 10000000000
if x < y: temp = y
else: temp = x
for i in range(0, temp * 2 + 1, 2):
    a_price = a * (x - int(i/2))
    b_price = b * (y - int(i/2))
    if a_price < 0:
        a_price = 0
    if b_price < 0:
        b_price = 0
    price = a_price + b_price + c * i
    # print(x - i/2, y - i/2, i, price)
    if price < mini:
        mini = price
print(mini)

Submission status: Accepted

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

min_value = a * x + b * y

max_num = max(x, y)

for i in range(2, max_num * 2 + 1, 2):
    # print(i)
    value = ab * i + a * max(0, x - i // 2) + b * max(0, y - i // 2)
    # print(value)
    min_value = min(min_value, value)

print(min_value)

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):
    if (max((x-i),0)*a + max((y-i),0)*b + c*2*i) < ans:
        ans = (max((x-i),0)*a + max((y-i),0)*b + c*2*i)
print(ans)

Submission status: Accepted

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

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

if a>c*2:
	if x>0:
		ans=ans+(x*2*c)
		x=0
elif x>0:
	ans=ans+(x*a)
	x=0

if b>c*2:
	if y>0:
		ans=ans+(y*2*c)
		y=0
elif y>0:
	ans=ans+(y*b)
	y=0

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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


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

    cost = A if X > Y else B
    piece = max(X, Y) - min(X, Y)

    for i in range(piece):
        ans = min(ans, ans - 2 * C + cost)
    print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

if a+b <= c*2:
    print(a*x +b*y)
else:
    if x>y:
        i=a
    elif x<y:
        i=b
    else:
        i=0
    
    p=min(x,y)*c*2 + abs(x-y)*i
    q=max(x,y)*c*2
    
    if p >= q:
        print(q)
    else:
        print(p)

Submission status: Accepted

Solution code:
import math
S = input().split(" ")

A = int(S[0])
B = int(S[1])
C = int(S[2])
X = int(S[3])
Y = int(S[4])

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


    base = min([x,y])

    values = []
    for index in range(base+1):
        tmp = 2 * C * index + a * (x - index) + b * (y - index)
        values.append(tmp)

    s2 = max([x,y]) * 2 * c
    values.append(s2)

    print(min(values))

calculate(A,B,C,X,Y)

Submission status: Accepted

Solution code:
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    A,B,C,x,y = LI()
    ans = float("inf")
    for c in range(200001)[::2]:
        a = b = c >> 1
        a = max(0,x-a)
        b = max(0,y-b)
        s = A*a+B*b+C*c
        if s < ans:
            ans = s
    print(ans)
    return

#Solve
if __name__ == "__main__":
    solve()

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

    mn = float('inf')
    for i in range(max(X,Y)+1):
        price = 0
        price += C * i
        if Y - i > 0:
            price += B * (Y - i)
        
        if X - i > 0:
            price += A * (X - i)
        
        mn = min(price, mn)
    
    print(mn)

if __name__ == '__main__':
    solve()

Submission status: Accepted

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

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

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

print(ans)

Submission status: Accepted

Solution code:
A, B, C, X, Y = map(lambda x: int(x), input().split())
price = A * X + B * Y
for Z in range(2, X * 2 + 1 if X > Y else Y * 2 + 1, 2):
    x, y = int(X - Z / 2), int(Y - Z / 2)
    x, y = 0 if x < 0 else x, 0 if y < 0 else y
    next_price = A * x + B * y + C * Z
    if next_price >= price:
        break
    price = next_price
print(price)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
a, b, c, x, y = map(int, input().split())

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

print(cost)

Submission status: Accepted

Solution code:
# pattern1:Only A-pizza/B-pizza
# pattern2:Only C-pizza
# pattern2:C-pizza & A or B-pizza

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

price1 = x * a + y * b
price2 = max(x, y) * 2 * c
price3 = min(x, y) * 2 * c + a * (x - min(x, y)) + b * (y - (min(x, y)))
print(min(price1, price2, price3))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A,B,C,X,Y = map(int,input().split())
A_and_B = A*X + B*Y
plus1AB = -(A+B)+2*C
if(plus1AB >= 0):
    print(A_and_B)
else:
    ABs= 2*C*min(X,Y)
    amari = abs(X-Y)
    if(X>=Y):
        only = amari*A
    else:
        only = amari*B
    ABonly = amari*2*C
    if(only >= ABonly):
        print(ABs + ABonly)
    else:
        print(ABs +only )

Submission status: Accepted

Solution code:
A, B, C, X, Y = map(int, input().split())
min1 = 10**18
max1 = max(X, Y)
for i in range(0, max1+1):
    if Y-i<0 and X-i<0:
        cnt = C*2*i
    elif Y-i<0:
        cnt = C*2*i + A*(X-i)
    elif X-i<0:
        cnt = C*2*i + B*(Y-i)
    else:
        cnt = C*2*i + A*(X-i) + B*(Y-i)
    if cnt<min1:
        min1 = cnt
print(min1)

Submission status: Accepted

Solution code:
import math
A,B,C,x,y=map(int,input().split())
price=5000*(10**6)
for c in range(1+max([2*x,2*y])):
    a=0
    b=0
    if x>c/2:
        a=math.ceil(x-(c/2))
    if y>c/2:
        b=math.ceil(y-(c/2))
    if A*a+B*b+C*c<price:
        price=A*a+B*b+C*c
print(price)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

ans = A*X+B*Y
Z=0
while True:
    X=max(X-1,0)
    Y=max(Y-1,0)
    Z=Z+2
    price=A*X+B*Y+C*Z
    #print(X,Y,Z,price)
    if ans > price:
        ans=price
    if X==0 and Y==0:
        break


print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

cost = []
##AとBを独立して買う
cost.append(A*X + B*Y)
##X<Yのとき,ABピザを買う
cost.append(2*C*X+abs(X-Y)*B)
##X>Y
cost.append(2*C*Y+abs(X-Y)*A)
##あまりを作るケース
cost.append(2*C*max(X,Y))

print(min(cost))

Submission status: Accepted

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

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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


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

elif a + b < c * 2:
    ans = (a * x) + (b * y)


print(ans)

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

loop=max(x*2,y*2)+1
ans=10**9

for i in range(loop):
  ab=i//2
  if x-ab>=0 and y-ab>=0:
    ans=min(ans,a*(x-ab)+b*(y-ab)+c*i)
  if x>=ab and y<ab:
    ans=min(ans,a*(x-ab)+c*i)
  if x<ab and y>=ab:
    ans=min(ans,b*(y-ab)+c*i)
  if x<ab and y<ab:
    ans=min(ans,c*i)
print(ans)

Submission status: Accepted

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

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

# ABセット(ABピザ2枚)をi個購入したとき、
# Aをmax(0, X-i)個買い増す必要があり、Bをmax(0, Y-i)個買い増す必要がある。
# 0 <= i <= 10^5 について、全探索し、最小値を求めればよい

price_min = 5000 * 2 * 100000
for i in range(0, 100000+1):
    price = 2*C*i + A * max(0, X-i) + B * max(0, Y-i)
    if price < price_min:
        price_min = price

print(price_min)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

yenmin=a*x+b*y
for zz in range(2*10**5+1):
    xx=max(x-zz//2,0)
    yy=max(y-zz//2,0)
    yen=a*xx+b*yy+c*zz
    if yen<yenmin:
        yenmin=yen
print(yenmin)
#print(xx,yy,zz)

Submission status: Accepted

Solution code:
A, B, C, X, Y = [int(x) for x in input().split(' ')]
if (A + B) / 2 > C:
  p = 10**10
  for i in range(min(X, Y), max(X, Y)+1):
    p = min(p, A * max(0, X-i) + B * max(0, Y-i) + C * i * 2)
  print(p)
else:
  print(A * X + B * Y)

Submission status: Accepted

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

MAX = max(X, Y)
MIN = 2*C*max(X, Y)
i = MAX
x=X
y=Y

while i > 0:
    tmpC = (MAX-i)*2*C
    total = (A*x)+(B*y)+tmpC
    if(MIN > total):
        MIN = total
    i-=1
    if(x!=0):
        x-=1
    if(y!=0):
        y-=1

print(MIN)

Submission status: Accepted

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

Submission status: Accepted

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

min_money = A*X + B*Y

status = np.array([X,Y,0])
delta_status = np.array([-1,-1,2])
block_status = np.array([0,0,0])
values = np.array([A,B,C])

for _ in range(max(X,Y)):
    status += delta_status
    status = np.max(np.array([status,block_status]), axis=0)
    
    tmp_money = sum(status * values)
    min_money = min(tmp_money,min_money)
print(min_money)

Submission status: Accepted

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

Submission status: Accepted

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