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 C >= A/2 + B/2:
  print(A*X+B*Y)
else:
  if X < Y:
#    add_cost_half = 2*(Y-X)*C
#    add_cost = (Y-X)*B
    ness_cost = 2*X*C
    add_cost_min = (Y-X)*min(2*C,B)
    total_cost = ness_cost + add_cost_min
    print(total_cost)
  elif X >= Y:
    ness_cost = 2*Y*C
    add_cost_min = (X-Y)*min(2*C,A)
    total_cost = ness_cost + add_cost_min
    print(total_cost)

Submission status: Accepted

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

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

Submission status: Accepted

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

ans = []

for z in range(0,max(X+1, Y+1)*2, 2):
    x = max(X - z//2, 0)
    y = max(Y - z//2, 0)
    ans.append((A * x) + (B * y) + (C * z))

print(min(ans))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a, b, c, x, y = [int(_) for _ in input().split()]
ans = 0
if a + b <= 2*c:
    ans = a * x + b * y
else:
    if x <= y:
        ans += x * 2 * c
        if b <= 2*c:
            ans += (y-x) * b
        else:
            ans += (y-x) * 2 * c
    else:
        ans += y * 2 * c
        if a <= 2*c:
            ans += (x-y) * a
        else:
            ans += (x-y) * 2 * c
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

ans1 = A*X + B*Y
ans2 = C*max(X,Y)*2

ans = C*MIN*2
X -= MIN
Y -= MIN
ans += A*X + B*Y

print(min([ans,ans1,ans2]))

Submission status: Accepted

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

Submission status: Accepted

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

pair = min(x,y)
cost = 0

if a + b > 2 * c:
    cost = 2 * c * pair
else:
    cost = (a + b) * pair

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

else:
    if b > 2 * c:
        cost = cost + 2 * c * (y - pair)
    else:
        cost = cost + b * (y - pair)

print(cost)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
A,B,C,X,Y = map(int, input().split())

prices = []
for c in range(0,max([X,Y])*2+1,2):
    a = max([X - c//2, 0])
    b = max([Y - c//2, 0])
    prices.append(A*a+B*b+C*c)

print(min(prices))

Submission status: Accepted

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

ans1 = a*x + b*y

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

ans3 = 2*c*max(x, y)
print(min(ans1, ans2, ans3))

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

Submission status: Accepted

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

print miny

Submission status: Accepted

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

Submission status: Accepted

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

m = a*x+b*y

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

Submission status: Accepted

Solution code:
A, B, C, X, Y = map(int, input().split())
price = A * X + B * Y
ma, mi = (X, Y) if X > Y else (Y, X)
ma_p, mi_p = (A, B) if X > Y else (B, A)

for i in range(1, ma+1):
    if i <= mi:
        temp = price - (ma_p + mi_p) + 2 * C
        if price > temp:
            price = temp
    else:
        temp = price - ma_p + 2 * C
        if price > temp:
            price = temp

print(price)

Submission status: Accepted

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

Submission status: Accepted

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

# 単体で買うより安い
if (a + b) > 2 * c:
    # 共通部分をABで買う方
    ans1 = c * min(x, y) * 2
    if x < y:
        ans1 += b * (y - x)
    else:
        ans1 += a * (x - y)
    
    # 余らせてでもABで買う方
    ans2 = c * max(x, y) * 2

    print(min(ans1, ans2))
else:
    ans = a * x + b * y 
    print(ans)

Submission status: Accepted

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

mi=min(x,y)

pr=0

if c*2<=a+b :
    pr+=c*2*mi
    x-=mi
    y-=mi

#print(pr)

if c*2<a :
    pr+=c*2*x
else :
    pr+=a*x

if c*2<b :
    pr+=c*2*y
else :
    pr+=b*y

print(pr)

Submission status: Accepted

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

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

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

Submission status: Accepted

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

ans = 0

if C <= A:
    ans += X * C
    Y -= X
    X = 0

if Y > 0 and C <= B:
    ans += Y * C
    X -= Y
    Y = 0

if X > 0 and Y > 0 and C <= A + B:
    cnt = min(X, Y)
    ans += cnt * C
    X -= cnt
    Y -= cnt

if X > 0:
    ans += X * A
    X = 0

if Y > 0:
    ans += Y * B
    Y = 0

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

cheapest=price_1
if price_2<cheapest:
	cheapest=price_2
if price_3<cheapest:
	cheapest=price_3
print(cheapest)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

if A >= C and B >= C:
    ans += max(X, Y) * C
elif C >= A+B:
    ans += A*X + B*Y
elif C >= max(A,B):
    if X>Y:
        ans += Y*C + (X-Y)*A
    else:
        ans += X*C + (Y-X)*B
else:
    if A >= C:
        ans += X*C
        if Y-X>0:
            ans+=(Y-X)*B
    else:
        ans += Y*C
        if X-Y>0:
            ans+=(X-Y)*A

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

total_ab = a * x + b * y
total_c = c * 2 * max(xy)
if x > y:
    total_abc = c * 2 * min(xy) + a * (x-y)
else:
    total_abc = c * 2 * min(xy) + b * (y-x)

total = [total_ab, total_c, total_abc]
print(min(total))

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

if  m==x:
    mm=a
    nn=b
else:
    mm=b
    nn=a

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

Submission status: Accepted

Solution code:
# coding: utf-8
from math import ceil

A,B,AB,x,y = list(map(int,input().split()))
p = []
for i in range(0,max(x,y)*2+1,2):
    ab = i
    a = max(0,ceil(x - (1/2)*i))
    b = max(0,ceil(y - (1/2)*i))
    p.append(A*a+B*b+AB*ab)
print(min(p))

Submission status: Accepted

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

ans = a*x+b*y

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

print(ans)

Submission status: Accepted

Solution code:
A,B,AB,AX,BY = map(int,input().split())

a = min(A+B, 2*AB)
if AX <= BY:
    ans = a * AX + (BY - AX) * min(B, 2*AB)
else:
    ans = a * BY + (AX - BY) * min(A, 2*AB)
print(ans)

Submission status: Accepted

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

ans = []

ans.append(A*X + B*Y)  # Aピザ、Bピザだけを使って買う

ans.append(2 * C*max(X, Y))  # ABピザだけを使って買う

if X > Y:
    ans.append(C*2*Y + A*(X-Y))

else:
    ans.append(C*2*X + B*(Y-X))

print(min(ans))

Submission status: Accepted

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

print(min(
          A * X + B * Y,
          C * 2 * min(X, Y) + A * max(0, (X - min(X, Y))) + B * max(0, (Y - min(X, Y))),
          C * 2 * max(X, Y) + A * max(0, (X - max(X, Y))) + B * max(0, (Y - max(X, Y)))))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A,B,C,X,Y = [int(i) for i in input().split()]
Sum = 0
if A+B<=2*C:
    Sum = A*X+B*Y
else:
    Min = min([X,Y])
    Sum+=Min*(2*C)
    Y-=Min;X-=Min
    if A*X+B*Y<=2*C*(X+Y):
        Sum+=A*X+B*Y
    else:
        Sum+=2*C*(X+Y)
print(Sum)

Submission status: Accepted

Solution code:
x = 0
y = 0
A,B,C,X,Y = map(int,input().split())
if X > Y :
    x = 1
else :
    y = 1
answer = min(X,Y)*min(A+B,C*2) + (max(X,Y)-min(X,Y))*(x*min(A,C*2)+y*min(B,C*2))
print(answer)

Submission status: Accepted

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

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

Submission status: Accepted

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

ab = min(C * 2, A + B) #A, B1枚ずつ用意するのにかかるお金の最小値
a = min(C * 2, A)
b = min(C * 2, B)
if X >= Y:
    print(ab * Y + a * (X - Y))
else:
    print(ab * X + b * (Y - X))

Submission status: Accepted

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

ans = 0

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

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

Submission status: Accepted

Solution code:
a,b,c,x,y = list(map(int,input().split()))
for i in range(100001):
    price_new = i*2*c + max(0, x-i)*a + max(0, y-i)*b
    if i==0:
        price = price_new
    else:
        price = min(price, price_new)

print(price)

Submission status: Accepted

Solution code:
import math

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

# cを全探索？
res = float('inf')
for i in range(max(x,y)*2+1):
    money = i * c
    if i/2<x:
        money += math.ceil(x-i/2) * a
    if i/2<y:
        money += math.ceil(y-i/2) * b
    res = min(res,money)

print(res)

Submission status: Accepted

Solution code:
A,B,C,X,Y = map(int, input().split())
if A+B < 2*C:
  ans = A*X+B*Y
else:
  XY = min(X,Y)
  ans = min(A*(X-XY) + B*(Y-XY) + 2*C*XY, 2*C*max(X,Y))
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(max(X,Y)+1):
  ans = min(ans, A*max(X-i,0)+B*max(Y-i,0)+C*i*2)
print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/python3

from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W

def main():
    A, B, C, X, Y = map(int, input().split())
    
    ans = INF
    for c in range(0, max(X, Y) * 2 + 1, 2):
        p = c * C
        p += max(0, A * (X - (c // 2)))
        p += max(0, B * (Y - (c // 2)))
        ans = min(ans, p)
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Thu Aug  9 23:51:35 2018

@author: Yuki
"""

A, B, AB, Acnt, Bcnt =map(int, input().split())

res = []
# AをAcnt枚, BをBcnt枚買う場合
res.append(A*Acnt+B*Bcnt)

# AcntとBcntの少ない方に到達するまでABを買い、残りは普通の買う場合
if Acnt >= Bcnt:
    res.append(Bcnt*2*AB+(Acnt-Bcnt)*A)
else:
    res.append(Acnt*2*AB+(Bcnt-Acnt)*B)

# 多い方までABを買う
res.append(max(Acnt, Bcnt)*2*AB)
print(min(res))

Submission status: Accepted

Solution code:
def main():
  t = input().split(" ")
  A, B, C, X ,Y = int(t[0]), int(t[1]), int(t[2]), int(t[3]), int(t[4])
  a_p = min(A, 2*C)
  b_p = min(B, 2*C)
  set_p = min(A+B, 2*C)
  set_n = min(X, Y)
  a_n = X - set_n
  b_n = Y - set_n
  r = a_p * a_n + b_p * b_n + set_p * set_n
  print(r)
main()

Submission status: Accepted

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

print(min(A+B, C*2) * min(X,Y) + (X - min(X,Y)) * min(A, C*2) + (Y - min(X,Y)) * min(B, C*2))

Submission status: Accepted

Solution code:
from collections import defaultdict
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
AtoZ = [chr(i) for i in range(65,65+26)]
atoz = [chr(i) for i in range(97,97+26)]

def inpl(): return list(map(int, input().split()))
def inpl_str(): return list(input().split())

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

#X<=Yに固定
if X > Y:
	X,Y = Y,X
	A,B = B,A

ans = 0
if A+B <= C*2: #セットがゴミ
	ans += X*A + Y*B
else:
	ans += X*2*C
	Y -= X
	ans += min(B*Y,C*2*Y)

print(ans)

Submission status: Accepted

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

# A 1枚、B 1枚を2C円で買うと捉え直す。
# ピザは、最大でも10**5枚（A, Bそれぞれに対して）
# A, Bのセットを、1~10**セットまで動かして一番安い組を考える

cheapest = float("inf")

for i in range(max(X, Y) + 1):

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

    cheapest = min(cheapest, price)

print(cheapest)

Submission status: Accepted

Solution code:
A, B, C, X, Y = map(int, input().split())
price = 0
min_num = min([X,Y])
if A/2 + B/2 > C:
    X -= min_num
    Y -= min_num
    if X == 0:
        print(min([min_num *2* C + B * Y, (Y+min_num)*2*C]))
    else:
        print(min([min_num *2* C + A * X, (X+min_num)*2*C]))
else:
    print(A*X+ B*Y)

Submission status: Accepted

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

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

Submission status: Accepted

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

print(min(a*x + b*y - (((a+b)-c*2)*min(x, y) if c*2 < a+b else 0), 2*c*max(x,y)))

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())

cand1 = A*X + B*Y
cand2 = 2*C*min(X,Y) + A * max(0,X-Y) + B * max(0,Y-X) 
cand3 = 2*C*max(X,Y)

print(min(cand1,cand2,cand3))

Submission status: Accepted

Solution code:
#coding:utf-8
a,b,c,x,y = map(int,input().split())
minv = a * x + b * y
c *= 2
big = max(x,y)
sml = min(x,y)
if a+b > c:
    minv = minv - (a+b) * sml + c * sml
if sml == x and b > c:
    minv = minv - (b-c) * (big - sml)
if sml == y and a > c:
    minv = minv - (a-c) * (big - sml)

print(minv)

Submission status: Accepted

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

Submission status: Accepted

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

min_amt = 2*10**5*5001

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

    ABset = 2 * C
    min_price = 0

    #ABsetのほうがA,Bを個別に買うより安い場合
    if ABset <= A + B:
        if X >= Y:
            min_price += ABset * Y
            min_price += min(A * (X - Y), ABset * (X - Y))
        if X < Y:
            min_price += ABset * X
            min_price += min(B * (Y - X), ABset * (Y - X))
    else:
        min_price += A * X + B * Y

    print(min_price)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

def main():
    base = min(X, Y)
    rest = max(X, Y) - base
    is_x = X > Y

    base_price = min(A + B, 2 * C) * base
    rest_price = min((A if is_x else B), 2 * C) * rest

    print(base_price + rest_price)

if __name__ == "__main__":
    main()

Submission status: Accepted

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

if max(X,Y)==X:
    price_sum_3=C*X*2
else:
    price_sum_3=C*Y*2
    
print(min(price_sum_1,price_sum_2,price_sum_3))

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

Submission status: Accepted

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

ans = float("INF")
for i in range(max(x, y)+1):
  t = c*2*i
  if x>i:
    t += (x-i)*a
  if y>i:
    t += (y-i)*b
  ans = min(ans, t)
print(ans)

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)

min_yen = 0

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

		if(X!=0 and (C*2 < B)):
			min_yen += C*2*Y
		elif(X!=0 and(C*2 >= B)):
			min_yen += B*Y

	else:
		min_yen += A*X

		if(C*2 < B):
			min_yen += C*2*Y
		else:
			min_yen += B*Y


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

		if(X!=0 and (C*2 < A)):
			min_yen += C*2*X
		elif(X!=0 and(C*2 >= A)):
			min_yen += A*X
	else:
		min_yen += B*Y

		if(C*2 < A):
			min_yen += C*2*X

		else:
			min_yen += A*X

print(min_yen)

Submission status: Accepted

Solution code:
A, B, C, X, Y = map(int, input().split())
mA = min(A,B)
MB = max(A,B)
mXY = min(X,Y)
if A != mA:
    AX = Y
    BY = X
else:
    AX = X
    BY = Y
A = mA
B = MB
X = AX
Y = BY
ans = 0
if A <= C and B <= C:
    ans = A*X + B*Y
else:
    if A + B <= 2*C:
        ans = mXY * (A+B)
        if X > Y:
            ans += A*(X - mXY)
        else:
            ans += B*(Y - mXY)
    else:
        ans = mXY * 2 * C
        if X > Y:
            ans += min(A,2*C)*(X-mXY)
        else:
            ans += min(B,2*C)*(Y-mXY)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A, B, C, X, Y = map(int, input().split())
s1 = A * X + B * Y
s2 = A * (X - min(X, Y)) + B * (Y - min(X, Y)) + C * 2 * min(X, Y)
s3 = C * 2 * max(X, Y)
print(min(s1, s2, s3))

Submission status: Accepted

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

if A+B<2*C:
    tmp=A+B
else:
    tmp=2*C

ans=tmp*min(X,Y)

#print(ans)

X2=X-min(X,Y)
Y2=Y-min(X,Y)

a1=X2*A+Y2*B
a2=X2*2*C+Y2*2*C

if a1<a2:
    print(ans+a1)
else:
    print(ans+a2)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a_price, b_price, c_price, a_target, b_target = map(int, input().split())

i = 0
i_max = 0
ans = float("inf")

if a_target > b_target:
    i_max = a_target
else:
    i_max = b_target

for i in range(0, i_max + 1):
    sum = i * c_price * 2 + max(0, a_target - i) * a_price + max(0, b_target - i) * b_price
    if sum < ans:
        ans = sum

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
A,B,C,X,Y=map(int,input().split())

ooiXY=max(X,Y)
sukunaiXY=min(X,Y)
ans1=C*ooiXY*2
ans2=A*X+B*Y
ans3=C*sukunaiXY*2+A*(X-sukunaiXY)+B*(Y-sukunaiXY)

print(min(ans1,ans2,ans3))

Submission status: Accepted

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


def abs0(inp):
    if inp < 0:
        return 0
    else:
        return inp


for i in range(x+1):
    a_l.append(a*i + c*2*(x-i) + b*abs0(y-(x-i)))
b_l = []
for i in range(y+1):
    b_l.append(b*i + c*2*(y-i) + a*abs0(x-(y-i)))
print(min(a_l + b_l))

Submission status: Accepted

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

Submission status: Accepted

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

if 2*c >= a+b: 
    print(a*x + b*y) # buy separately
else:
    if max(x,y) == x:
        if a <= 2*c:  print((x-y)*a + y*2*c)
        else:         print(x*2*c)
            
    else: # max(x,y) == y
        if b <= 2*c:  print((y-x)*b + x*2*c)
        else:         print(y*2*c)

Submission status: Accepted

Solution code:

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

    y1 = a * x + b * y
    y2 = c * max(x, y) * 2
    if x >= y:
        y3 = c * y * 2
        y3 += a * (x - y)
    else:
        y3 = c * x * 2
        y3 += b * (y - x)
    print(min(y1, y2, y3))

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
A, B, C, X, Y = map(int, input().split())
sum1 = A * X + B * Y
sum2 = C * min(X, Y) * 2 + A * (X - min(X, Y)) + B * (Y - min(X , Y))
sum3 = C * max(X, Y) * 2
print(min(sum1, sum2, sum3))

Submission status: Accepted

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

if X>=Y:
    bigger = A
else:
    bigger = B


common = max(X,Y) - abs(X-Y)
if (A+B)/2 < C:
    total = A*common + B*common
else:
    total = C*common*2

difference = abs(X-Y)
if bigger < C*2:
    total = total + bigger*difference
else:
    total = total + difference*C*2


print(total)

Submission status: Accepted

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

Submission status: Accepted

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

print(kingaku)

Submission status: Accepted

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

money = 0
if A + B >= C*2:
    t = min(X,Y)
    money += t * 2 * C
    X -= t
    Y -= t
    if X > 0:
        if A > C*2:
            money += C * 2 * X
        else:
            money += A * X
    elif Y > 0:
        if B > C*2:
            money += C * 2 * Y
        else:
            money += B * Y
else:
    money += A * X + B * Y
print(money)

Submission status: Accepted

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

Submission status: Accepted

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

AB *= 2
result = [A*X+B*Y, AB*max(X,Y), AB*Y+A*(X-Y) if X>Y else AB*X+B*(Y-X)]

print(min(result))

Submission status: Accepted

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

AB *= 2
result = [A*X+B*Y, AB*max(X,Y), AB*Y+A*(X-Y) if X>Y else AB*X+B*(Y-X)]

print(min(result))

Submission status: Accepted

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

price = min(A*X+B*Y, C*2 * (max(X, Y)))

is_break = 0

for i in range(100000):
    if price >= A*max(0, X - i) + B*max(0, Y - i)+2*C*i:
        price = A*max(0, X - i) + B*max(0, Y - i)+2*C*i
print(price)

Submission status: Accepted

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

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

print(total)

Submission status: Accepted

Solution code:
A, B, C, X, Y = map(int, input().split())
sum1 = A * X + B * Y
sum2 = A * (X - min(X, Y)) + B * (Y - min(X, Y)) + C * 2 * min(X, Y)
sum3 = C * 2 * max(X, Y)
print(min(sum1, sum2, sum3))

Submission status: Accepted

Solution code:
A,B,C,X,Y = (int(i) for i in input().split())
i = 0
a = []
while i <= 100000:
    p = i * 2*C + A*max(0,X-i)+B*max(0,Y-i)
    a.append(p)
    i += 1
print(min(a))

Submission status: Accepted

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

minValue = float('inf')

for i in range(0,100001):
    total = 2 * i * C + max([0,X-i]) * A + max([0,Y-i]) * B
    
    if minValue > total:
        minValue = total

print(minValue)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
A, B, C, X, Y = map(int, input().split( ))
direct = A*X + B*Y
if X < Y:
    rearrange = C*2*X+B*(Y-X)
else:
    rearrange = C*2*Y+A*(X-Y)
combi = C*2*max(X,Y)
print(min(direct, rearrange, combi))