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

def main():

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

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

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

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

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

a,b,ab = 0, 0, 0

a = X
b = Y
ab = 0

m = a * A + b * B + ab * C
big = max(X,Y)
while ab // 2 <= big:
    ab += 2
    if a > 0:
        a -= 1
    if b > 0:
        b -= 1
    m = min(m, a * A + b * B + ab * C)

print(m)

Submission status: Accepted

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

    if ans > (i*c)+(xr*a)+(yr*b):
        ans = (i*c)+(xr*a)+(yr*b)

print(ans)

Submission status: Accepted

Solution code:
# ABピザを使うんなら効率的に使う、をやるとO(1)
a, b, c, x, y = map(int, input().split())
t = (x - y) * a if x > y else (y - x) * b
# 順に、ABピザを「使わない」「一部使う（必要枚数が少ないほうに合わせる。不足するピザはそのピザだけを買う）」「全部使う（必要枚数が多い方に合わせる。あまったピザ上等）」
print(min(a * x + b * y, 2 * c * min(x, y) + t, 2 * c * max(x, y)))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
# モジュールのインポート
import sys

# 標準入力を取得
A, B, C, X, Y = list(map(int, input().split()))

# 求解処理
ans = sys.maxsize
for c in range(0, 2 * max(X, Y) + 1, 2):
    a = max(0, X - c // 2)
    b = max(0, Y - c // 2)
    ans = min(ans, A * a + B * b + C * c)

# 結果出力
print(ans)

Submission status: Accepted

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


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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:

a_yen, b_yen, c_yen, x, y = map(int, input().split())

amax = x
bmax = y
cmax = max(x,y) * 2

nedan = 10**10

for i in range(cmax//2+1):
    c=i*2
    
    a=max(amax-c//2,0)
    b=max(bmax-c//2,0)
    
    yen = a_yen * a + b_yen * b +c_yen * c
    # print(a,b,c,yen)
    nedan = min(nedan,yen)

print(nedan)

Submission status: Accepted

Solution code:
x=input().split()
x=[int(x[i]) for i in range(len(x))]
if x[0]+x[1]<=2*x[2]:
    print(x[0]*x[3]+x[1]*x[4])
else:
    if x[3]>x[4]:
        ans=x[4]*2*x[2]+(x[3]-x[4])*x[0]
        ans=min(ans,x[3]*2*x[2])
    else:
        ans=x[3]*2*x[2]+(x[4]-x[3])*x[1]
        ans=min(ans,x[4]*2*x[2])
    print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
#「ABピザを買う枚数」で全探索

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

ans = float("inf")

for i in range(0,2*max(X,Y)+1,1):#「ABピザを買う枚数」で全探索
    tmpans = i*C#ABピザの代金

    tmp_x = max(0,X-i//2)
    tmp_y = max(0,Y-i//2)
    tmpans += A*tmp_x
    tmpans += B*tmp_y

    ans = min(ans,tmpans)

print(ans)

Submission status: Accepted

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

count = a * x + b * y
for i in range(10 ** 6):
  num = i * 2 * c + max(0, x - i) * a + max(0, y - i) * b
  if(count > num):
    count = num

print(count)

Submission status: Accepted

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

Submission status: Accepted

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

ans = float('inf')
for i in range(10 ** 5 + 1):
    price = i * 2 * c
    if x > i:
        price += a * (x - i)
    if y > i:
        price += b * (y - i)
    ans = min(ans, price)

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
if __name__ == '__main__':

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

	#A,Bのみで買った場合
	tmp1 = (a * x) + (b * y)

	#A-Bで買った場合 量は2倍になる
	mi = min(x,y)

	tmp2 = mi * c * 2

	#A-Bで買った場合 残りの判定
	if x - mi == 0:
		#Bをそのまま買う
		tmp3 = b * (y - mi)
		
		#ABを買う(残りのAは捨てる)
		tmp4 = c * (y - mi) * 2
		
		tmp2 += min(tmp3,tmp4)
		
	else:
		#Aをそのまま買う
		tmp3 = a * (x - mi)
		
		#ABを買う(残りのBは捨てる)
		tmp4 = c * (x - mi) * 2
		
		tmp2 += min(tmp3,tmp4)

	#判定
	print(min(tmp1,tmp2))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    A,B,C,X,Y = [int(x) for x in input().split()]
    ans = 0
    if A+B <= C*2:
        ans = A*X + B*Y
    else:
        if X<=Y:
            ans = C*X*2 + min(B,C*2)*(Y-X)
        elif X>Y:
            ans = C*Y*2 + min(A,C*2)*(X-Y)
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import math

def main():
    A,B,C,X,Y = [int(x) for x in input().split()]
    ans = 0
    if A+B <= C*2:
        # print('b')
        ans = A*X + B*Y
    else:
        if X<=Y:
            # print('c')
            ans = C*X*2 + min(B,C*2)*(Y-X)
        elif X>Y:
            # print('d')
            ans = C*Y*2 + min(A,C*2)*(X-Y)
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

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

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

print(min(res, temp))

Submission status: Accepted

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

print(mn)

Submission status: Accepted

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

smallestSum = 0
tempSum = 0

smallestSum = a * x + b * y

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

print(smallestSum)

Submission status: Accepted

Solution code:
A, B, C, X, Y = map(int, input().split())
#初期値
x = X ; y = Y
mn = 1e10
if 2*C-(A+B) >= 0 :
    ans = A * x + B * y
    print(ans)
else :
    for z in range(0,max(X,Y)*2+1,2) :
        if x > 0 and y > 0 :
            ans = A*x + B*y + C*z
            mn = min(mn,ans)
            x -= 1 ; y -= 1
        elif x > 0 and y == 0 :
            ans = A*x + C*z
            mn = min(mn, ans)
            x -= 1
        elif x == 0 and y > 0 :
            ans = B*y + C*z
            mn = min(mn, ans)
            y -= 1
        else :
            ans = C*z
            mn = min(mn, ans)
    print(mn)

Submission status: Accepted

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

if a>= c*2 and b >= c*2:
    print(max(x,y)*c*2)

elif a>= c*2 and x>=y :
    print(x*c*2)

elif b >= c*2 and y>=x:
    print(y*c*2)

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

Submission status: Accepted

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

ans = a*x+b*y

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A,B,C,X,Y = (int(X) for X in input().split())
MINPrice = pow(10,9)
for ABP in range(0,2*max(X,Y)+1,2):
    Price = A*max(0,(X-ABP//2))+B*max(0,(Y-ABP//2))+C*ABP
    if Price<=MINPrice:
        MINPrice = Price
print(MINPrice)

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):
    ans = min(ans, i * C + max(X-(i//2), 0) * A + max(Y-(i//2), 0) * B)
print(ans)

Submission status: Accepted

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

single = a*x+b*y
pair_max = 2*c*max(x, y)
pair_min = 2*c*min(x, y) + a*abs(x-y)*(x>y) + b*abs(x-y)*(x<y)

print(min(single, pair_max, pair_min))

Submission status: Accepted

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

if X>=Y:ans,Ccnt=C*X*2,X*2
else:ans,Ccnt=C*Y*2,Y*2

for c in range(1,Ccnt//2+1):
	
	temp=(Ccnt-2*c)*C
	if (Ccnt-c*2)//2<Y:
		temp+=(Y-(Ccnt-c*2)//2)*B
	if (Ccnt-c*2)/2<X:
		temp+=(X-(Ccnt-c*2)//2)*A
	#print(X-(Ccnt-c*2)/2,Y-(Ccnt-c*2)/2,Ccnt-2*c,temp)
	ans=min(ans,temp)

print(ans)

Submission status: Accepted

Solution code:
a,b,c,x,y=map(int,input().split())
if x>y:
  a,b=b,a
  x,y=y,x
ans1=0
if a+b>2*c:
  ans1=2*x*c
else:
  ans1=x*a+x*b
y-=x
ans2=10**100
for i in range(y+1):
  tmp=b*i+c*2*(y-i)
  if tmp<ans2:
    ans2=tmp
print(ans1+ans2)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
# coding: utf-8

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


n = 10 ** 10
min_a = min_b = min_c = 10**10
max_ab = 0
for ab in range(0, 2*max(X, Y) + 2, 2):
    a = max(X - ab//2, 0)
    b = max(Y - ab//2, 0)
    n = min(n, a*A + b*B + ab*C)

print(n)

Submission status: Accepted

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

result = float('inf')
for i in range(0, max(X, Y)+1):
    tmp = C*2*i + max(0, X-i) * A + max(0, Y-i) * B
    if tmp < result:
        result = tmp
print(result)

Submission status: Accepted

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

a = A*X+B*Y
b = max(X,Y)*C*2
c = min(X,Y)*C*2
if max(X,Y) == X:
    c += (X-Y)*A
else:
    c += (Y-X)*B

print(min(min(a,b),c))

Submission status: Accepted

Solution code:
def resolve():
    A, B, C, X, Y = list(map(int, input().split()))
    MAX = 2 * max(X,Y)
    ans = 10 ** 14

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

    print(ans)
    return

resolve()

Submission status: Accepted

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

if x > y:
    l += (x - y) * a
    p = y
elif x < y:
    l += (y - x) * b
    p = x
else:
    pass
l += p * 2 * c
n = max(x,y) * 2 * c
m = x * a + y * b
print(min(l,n,m))

Submission status: Accepted

Solution code:
import sys


def main():
    input = sys.stdin.buffer.readline
    a, b, c, x, y = map(int, input().split())
    ans = 0
    if 2 * c < a + b:
        m = min(x, y)
        ans += 2 * c * m
        x -= m
        y -= m
    if 2 * c < a:
        ans += 2 * c * x
        x = 0
    if 2 * c < b:
        ans += 2 * c * y
        y = 0
    ans += a * x + b * y
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:

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

anslist=[]

for i in range(0,2*max(X,Y)+1,2):
    ans=C*i
    if X>i//2:
        ans=ans+A*(X-i//2)
    if Y>i//2:
        ans=ans+B*(Y-i//2)
    anslist.append(ans)
print(min(anslist))

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A, B, C, X, Y = map(int, input().split())
C *= 2
t,s,P = 0,max(X,Y),1000000000000
while s>=0:
  P = min(P, C*s+A*max(X-s, 0)+B*max(Y-s, 0))
  s -= 1
print(P)

Submission status: Accepted

Solution code:
def resolve():
    A, B, C, X, Y = [int(i) for i in input().split()]
    # Cを0～max(X,Y)の2倍まで購入
    minA = float("inf")
    for i in range(0, max(X, Y) * 2 + 1, 2):
        sumA = C * i
        sumA += (A * (X - i // 2) if (X - i // 2) > 0 else 0)
        sumA += (B * (Y - i // 2) if (Y - i // 2) > 0 else 0)
        minA = min(minA, sumA)
    print(minA)


resolve()

Submission status: Accepted

Solution code:
# xとyどっちを優先にするか
# -> これだとなんかできそうでできない ABピザとハイブリッドしたほうが得な場合もありそう（多分
# 「ABピザをいくつ使うか」固定して全探索してみる

a, b, c, x, y = map(int, input().split())
ans = 10**18
for i in range(2 * 10**5 + 100):
    # ABピザi枚使ったとする（奇数枚はありえないので2倍
    p = 2 * c * i + a * (max(0, x - i)) + b * (max(0, y - i))
    # print(f"ABピザを{2*i}枚使ったよ p={p}")
    ans = min(ans, p)
print(ans)

Submission status: Accepted

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

for i in range(0, max(x, y) + 1):
    c_price = i * 2 * c
    if x - i <= 0:
        a_price = 0
    else:
        a_price = (x - i) * a
    if y - i <= 0:
        b_price = 0
    else:
        b_price = (y - i) * b
    total.append(a_price + b_price + c_price)
print(min(total))

Submission status: Accepted

Solution code:
# coding: utf-8

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

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

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

Submission status: Accepted

Solution code:
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
a,b,c,x,y = readInts()
c *= 2
if x > y:
    # 3 通り
    # a,b を x,y個ずつ買う
    # 2枚セットを大きいほう個買う
    # 2枚セットを小さい方買う、のこりは大きい方
    ans = min(a*x + b*y, c * x, c*y + a*(x-y))
else:
    ans = min(a*x + b*y, c*y, c*x+b*(y-x))
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Price = []

for k in range(min(x, y)+1):
  Price.append((2*c-a-b)*k + a*x + b*y)
Price.append(max(x,y)*2*c)

print(min(Price))

Submission status: Accepted

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

Submission status: Accepted

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

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

    less = abs(x - y)
    p = a if x > y else b
    if 2 * c < p:
        cnum += 2 * less
        less = 0

    ans = c * cnum + less * p

print(ans)

Submission status: Accepted

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

A,B,C,X,Y = list(map(int,input().split()))
cost = A*X+B*Y
if X >= Y:
    maxXY = X
    maxAB = A
else:
    maxXY = Y
    maxAB = B
ans = cost
for xy in range(1,maxXY+1):
    nc =  2*C*xy +max(0,(X-xy))*A+max(0,(Y-xy))*B
    #print(nc,cost)
    if nc < cost: 
        ans = min(ans,nc)
print(ans)

Submission status: Accepted

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

ans1 = a * x + b * y
ans2 = min(x, y) * 2 * c + [a, b][max(x, y) == y] * abs(x - y)
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())
pmin = 10**10
for i in range(max(x, y)+1): # 2i枚のABピザを買う
    bx = max(0, x - i)
    by = max(0, y - i)
    pay = a*bx + b*by + 2*c*i
    pmin = min(pmin, pay)


print(pmin)

Submission status: Accepted

Solution code:
a, b, c, x, y = map(int, input().split())
pmin = 10**10
for i in range(0, 2*max(x, y)+1, 2): # i枚のABピザを買う
    bx = max(0, x - i//2)
    by = max(0, y - i//2)
    pay = a*bx + b*by + c*i
    pmin = min(pmin, pay)


print(pmin)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    import sys
    def input(): return sys.stdin.readline().rstrip()
    a, b, c, x, y = map(int, input().split())
    lim = max(x, y)
    ans = 10**12
    for i in range(lim+1):
        price = a*max(0, x-i) + b*max(0, y-i) + c*2*i
        ans = min(ans, price)
    print(ans)

if __name__ == '__main__':
    main()

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, 2*Y*C)
    ans = min(ans, 2*X*C+(Y-X)*B)
else:
    ans = min(ans, 2*X*C)
    ans = min(ans, 2*Y*C+(X-Y)*A)
print(ans)

Submission status: Accepted

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

ans=0

if 2*C >= A+B:#A,Bを個別に買う
#     print('a')
    ans = A*X+B*Y
else:
    if 2*C <= A and 2*C <= B:
        if X >= Y:
#             print('b_1')
            ans = C*2*X
            
        elif X < Y:
#             print('b_2')
            ans = C*2*Y
            
    elif 2*C <= A:
#         print('b')
        ans = C*2*X + max(0,Y-X)*B
    elif 2*C <= B:
#         print('c')
        ans = max(0,X-Y)*A + C*2*Y
    else:
        if X <= Y:
#             print('d_1')
            ans = C*2*X + max(0,Y-X)*B
            
        elif X > Y:
#             print('d_2')
            ans = max(0,X-Y)*A + C*2*Y
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

res = A*X + B*Y

m = 2 * C * max(X, Y);

sum = C * 2* min_

if(C<=0.5 * A and C <= 0.5 * B):
    sum += 2*C*(max_-min_)

elif(max_==X):
    sum += (max_-min_)*A
else:
    sum += (max_-min_)*B
    
print(min(m,min(res,sum)))

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
from collections import deque, defaultdict
from math import sqrt, factorial
# def input(): return sys.stdin.readline()[:-1] # warning not \n
# def input(): return sys.stdin.buffer.readline().strip() # warning bytes
# def input(): return sys.stdin.buffer.readline().decode('utf-8')


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

t = 1
# t = int(input())
for case in range(1,t+1):
    ans = solve()


"""

a aa c ca c a b a ab a b c

"""

Submission status: Accepted

Solution code:
import sys
import math
a,b,c,x,y = map(int,input().split())
ans=0
i=0
j=0
while True:
    if i==x and j==y:
        break
    elif i==x:
        if c*2<b:
            ans+=c*2
        else:
            ans+=b
        j+=1
    elif j==y:
        if c*2<a:
                ans+=c*2
        else:
            ans+=a
        i+=1
    else:
        if c*2<(a+b):
            ans+=c*2
        else:
            ans+=a+b
        i+=1
        j+=1
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

# strategy 1: buy only AB                                                                                                                                                                                   

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

# strategy 2: buy only A and B                                                                                                                                                                              
a2 = A * X + B * Y

# strategy 3: buy AB until one is satisfied                                                                                                                                                                 
a3 = 2 * C * min(X, Y) + A * (X-min(X, Y)) + B * (Y-min(X, Y))

print(min(a1, a2, a3))

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
a, b, c, x, y = map(int, input().split())
print(
    min(
        a * x + b * y,
        max(x, y) * c * 2,
        c * x * 2 + (y - x) * b if y > x else c * y * 2 + (x - y) * a if x > y else 10**9,
    ))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

if X <= Y:
  S = B
  Z = X
  W = Y
else:
  S = A
  Z = Y
  W = X
  
if 2*C > A+B:
  print(A*X+B*Y)

elif 2*C > S:
  print((2*C-S)*Z + S*W)
  
else:
  print(2*C*W)

Submission status: Accepted

Solution code:
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
def gcd(*numbers): reduce(math.gcd, numbers)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
count = 0
ans = 0

a,b,c,x,y = I()
p = []
for i in range(10**5+1):
    cash = 2*c*i+a*max(0,x-i)+b*max(0,y-i)
    p.append(cash)

print(min(p))

Submission status: Accepted

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

ans=10**12
for i in range(max(X,Y)+1):
    cnt=0
    cnt+=i*C*2
    cnt+=max(0,X-i)*A
    cnt+=max(0,Y-i)*B
    ans=min(ans,cnt)
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):
  pa=max(0,x-i)
  pb=max(0,y-i)
  temp = c*2*i+a*pa+b*pb
  ans=min(ans,temp)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

price=1000000000
for p in range(0,max(X,Y)*2+1,2):
    q=max(0,X-p//2)
    r=max(0,Y-p//2)
    if price>p*C+q*A+r*B:
        price=p*C+q*A+r*B
print(price)

Submission status: Accepted

Solution code:
A, B, C, X, Y = map(int, input().split())
ans = None
for ab_count in range(0, max(X, Y) * 2 + 1, 2):
    a_count = max(0, X - ab_count // 2)
    b_count = max(0, Y - ab_count // 2)
    amount = a_count * A + b_count * B + ab_count * C
    if ans is None:
        ans = amount
    else:
        ans = min(ans, amount)
print(ans)

Submission status: Accepted

Solution code:
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

a,b,c,x,y = nm()

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