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())
ans=float('inf')
for i in range(10**5+1):
    tmp=2*i*c+a*max(x-i,0)+b*max(y-i,0)
    ans=min(tmp,ans)
print(ans)

Submission status: Accepted

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

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

print(res)

Submission status: Accepted

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

ans += min(a+b,c)*z

ans += min(v,c)*w

print(ans)

Submission status: Accepted

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

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

ans = 2*5000*100000
for k in range(100001):
    tmp = 2*c*k + max(x-k, 0)*a + max(y-k, 0)*b
    ans = min(ans, tmp)
print(ans)

Submission status: Accepted

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

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

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

print(min(naive, recon, over))

Submission status: Accepted

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

print(cnt)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
import sys

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

A, B, C, X, Y = lr()
if X > Y:
    A, B = B, A
    X, Y = Y, X
# X < Y の条件
AB2 = 2 * C
answer = 0
if AB2 < A + B:
    answer += AB2 * X
    Y -= X; X = 0
else:
    answer += (A + B) * X
    Y -= X; X = 0
if AB2 < B:
    answer += AB2 * Y
else:
    answer += B * Y

print(answer)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

ans = a * x + b * y
cnt = 1

while x != 0 or y != 0:
  x = max(x - 1, 0)
  y = max(y - 1, 0)
  ans = min(ans,a*x+b*y+c*2*cnt)
  cnt += 1
print(ans)

Submission status: Accepted

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

#雰囲気
ans = a * x + b * y
cnt = 1
while x != 0 or  y!= 0:
    x = max(x - 1, 0)
    y = max(y - 1, 0)
    ans = min(ans,a*x+b*y+c * 2 * cnt)
    cnt += 1
    #print(ans,x,y)
print(ans)

Submission status: Accepted

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

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

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

ans = A*X + B*Y
tmp = A*X + B*Y
x = X
y = Y
z = 0

while x >= 0 or y >= 0:
    tmp = A*max(0,x) + B*max(0,y) + C*z
    ans = min(ans,tmp)
    x=x-1
    y=y-1
    z=z+2

print(ans)

Submission status: Accepted

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

ans = A*X + B*Y
tmp = A*X + B*Y
x = X
y = Y
z = 0

while x >= 0 or y >= 0:
    if x<0 and y<0:
        tmp = C*z
    elif x<0:
        tmp = B*y + C*z
    elif y<0:
        tmp = A*x + C*z
    else:
        tmp = A*x + B*y + C*z
    ans = min(ans,tmp)
    x=x-1
    y=y-1
    z=z+2

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

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

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

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:
    ans = 2*C*max(X, Y)

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

Submission status: Accepted

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

    pizzamax = [x for x in range(max(x,y)+1)]
    pizzamax.sort(reverse=True)

    paymin = 5000 * 2 * 10**5
    for i in pizzamax:
        pay = 2 * i * c
        if i < x:
            pay += (x-i) * a
        if i < y:
            pay += (y-i) * b
        paymin = min(paymin, pay)

    print(paymin)
resolve()

Submission status: Accepted

Solution code:
a,b,c,x,y=map(int,input().split())
z=min(x,y)
z_max=max(x,y)
cost=0

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

print(cost)

Submission status: Accepted

Solution code:
a,b,c,x,y=map(int,input().split())
yasui=False
yasuia=False
yasuib=False
ans=0
sa=max([x,y])-abs(x-y)
if a+b>2*c:
  yasui=True
if a>2*c:
  yasuia=True
if b>2*c:
  yasuib=True
if yasui:
  ans+=sa*2*c
else:
  ans+=sa*(a+b)
x-=sa
y-=sa

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import numpy as np

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

m = min(X,Y)
p = np.abs(X-Y)

A_B_only = A*X+B*Y
A_B = A*m+B*m+p*2*C

if X<Y:
  AB = m*2*C+p*B
  AB_only = Y*2*C
elif Y<X:
  AB = m*2*C+p*A
  AB_only = X*2*C
elif X==Y:
  AB = m*2*C
  AB_only = X*2*C


print(min(A_B,AB,AB_only,A_B_only))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

cmin=max([X,Y])
lis=[]
for i in range(cmin+1):
	i_c=i*2
	i_a, i_b=X-i,Y-i
	# print(i_a,i_b,i_c)
	if i_a>=0 and i_b>=0:
		lis.append(i_c*C+i_b*B+i_a*A)
	if i_a<0:
		if i_b<0:
			lis.append(i_c*C)
		else:
			lis.append(i_c*C+i_b*B)
	elif i_b<0:
		lis.append(i_c*C+i_a*A)


print(min(lis))

Submission status: Accepted

Solution code:
import sys
INFTY=sys.maxsize

def readinput():
    a,b,c,x,y=list(map(int,input().split()))
    return a,b,c,x,y

def main(a,b,c,x,y):
    minPrice=INFTY
    for nab in range(0,max(x,y)*2+1,2):
        na=max(0,x-nab//2)
        nb=max(0,y-nab//2)
        price=nab*c+na*a+nb*b
        #print(price, na, nb, nab)
        minPrice=min(minPrice,price)  
    return minPrice  

if __name__=='__main__':
    a,b,c,x,y=readinput()
    ans=main(a,b,c,x,y)
    print(ans)

Submission status: Accepted

Solution code:
def calc(s, l, c, x, y):
    pat1 = s*x + l*y
    pat2 = 2*c*y
    pat3 = 2*c*x + l*(y-x)
    return min(pat1,pat2,pat3)

A,B,C,X,Y = map(int, input().split())
if X < Y:
    print(calc(A,B,C,X,Y))
else:
    print(calc(B,A,C,Y,X))

Submission status: Accepted

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

fee = 0

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

print(fee)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#Order can be reduced by diving cases but full search on purpose
a, b, c, x, y = map(int, input().split())
num = float("inf")
for i in range(max(x, y) + 1):
    num = min(num, a * max(0, (x - i)) + b * max(0, (y - i)) + 2 * c * i)
print(num)

Submission status: Accepted

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

Submission status: Accepted

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

ans=10**10

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

print(ans)

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
A,B,C,X,Y = map(int,readline().split())
AB = 2*max(X,Y)
price = float('inf')
for i in range(0,AB+1,2):
  total = A * max(0,X-i//2)+ B * max(0,Y-i//2) + C * i 
  price = min(price,total)
print(price)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
input = input()
split = input.split()
pliceA = int(split[0])
pliceB = int(split[1])
pliceC = int(split[2])
neededA = int(split[3])
neededB = int(split[4])

maxC = neededA * 2 if neededA > neededB else neededB * 2
minPlice = 10 ** 10
for c in range(0, maxC + 1, 1):
    leftA = neededA - int(c / 2) if neededA - int(c / 2) > 0 else 0
    leftB = neededB - int(c / 2) if neededB - int(c / 2) > 0 else 0
    plice = leftA * pliceA + leftB * pliceB + pliceC * c
    minPlice = plice if plice < minPlice else minPlice

print(minPlice)

Submission status: Accepted

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

#a,b別々
ans = a * x + b * y

#全てabで作る
ans = min(ans, c * 2 * max(x,y))

if x - y > 0:
    # 残りをaで買う
    t = c * 2 * y
    t += a * (x - y)
    ans = min(ans, t)
else:
    # 残りをbで買う
    t = c * 2 * x
    t += b * (y - x)
    ans = min(ans, t)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

print(min(k1, k2, k3))

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

    ans = 1 << 30
    c = 0  # even
    while True:
        j = c // 2
        t = A * max(0, X - j) + B * max(0, Y - j) + C * c
        if ans <= t: break
        ans = t
        c += 2

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

d = c * 2


ans = 1 << 30
# ABを何枚
for i in range(max(x, y) + 1):
    rx = max(x - i, 0)
    ry = max(y - i, 0)
    ans = min(ans,  i * d + rx * a + ry * b)
print(ans)

Submission status: Accepted

Solution code:
# abc95 c
a,b,c,x,y = map(int, input().split())
cost = 0
# 両方のピザをmin(x,y)枚買うー＞足りない方をabs(x-y)枚買う
if a+b >= 2*c:
    cost += 2*c*min(x,y)
else:
    cost += (a+b)*min(x,y)

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

Submission status: Accepted

Solution code:
import math
import string
import collections
from collections import Counter
from collections import deque
from decimal import Decimal
import sys
import fractions


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


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]
a, b, c, x, y = map(int, input().split())
#print(a, b, c, x, y)
ab = math.floor((x+y)/2)
#print('ab', ab)
p1 = a*x+b*y
max_x = max(x, y)
p2 = c*max_x+c*max_x
min_x = min(x, y)
p3 = a*(x-min_x)+b*(y-min_x)+c*((min_x)*2)
ans = min(p1, p2, p3)
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(total)

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().strip()

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import stdin
from sys import setrecursionlimit
setrecursionlimit(10 ** 7)

a,b,c,x,y = map(int,stdin.readline().rstrip().split())
mi = 10**10

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

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

print(mi)

Submission status: Accepted

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

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

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    a, b, c, x, y = map(int, input().split())
    c *= 2
    if a + b > c:
        cost1 = max(x, y) * c
        cost2 = min(x, y) * c
        plus = ((y - x) * b) if x < y else (x - y) * a
        res = min(cost1, cost2 + plus)
    else:
        res = x * a + y * b
    print(res)

if __name__ == '__main__':
    resolve()

Submission status: Accepted

Solution code:
def resolve():
  a, b, c, x, y = map(int, input().split())
  ans = a * x + b * y
  # A を AB で代替する
  ans = min(ans, c * x * 2 + max(0, b * (y - x)))
  # B を AB で代替する
  ans = min(ans, c * y * 2 + max(0, a * (x - y)))

  print(ans)
  return

if __name__ == "__main__":
  resolve()

Submission status: Accepted

Solution code:
a, b, c, x, y = map(int, input().split())
ans = 10 ** 18
for i in range(10 ** 5 * 2):
    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 = map(int, input().split())

cost = 0

ab = min(X, Y)
cost += min(ab * 2 * C, (A + B) * ab)
X -= ab
Y -= ab

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

print(cost)

Submission status: Accepted

Solution code:
def examA():
    C1 = SI()
    C2 = SI()
    ans = "YES"
    if C1[0]!=C2[2] or C1[1]!=C2[1] or C1[2]!=C2[0]:
        ans = "NO"
    print(ans)
    return

def examB():
    A, B, C, X, Y = LI()
    loop = max(X,Y)
    ans = inf
    for i in range(loop+1):
        cost = i*2*C
        if X>i:
            cost += A*(X-i)
        if Y>i:
            cost += B*(Y-i)
        ans = min(ans,cost)
    print(ans)
    return

def examC():
    ans = 0
    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

from decimal import Decimal as dec
import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def I(): return int(input())
def LI(): return list(map(int,sys.stdin.readline().split()))
def DI(): return dec(input())
def LDI(): return list(map(dec,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

sys.setrecursionlimit(10**7)

if __name__ == '__main__':
    examB()

"""
142
12 9 1445 0 1
asd dfg hj o o
aidn
"""

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#ABC095C
def main():
    import sys
    A,B,C,X,Y = map(int, sys.stdin.readline().split())
    # cをi枚とする
    ans = -1
    for i in range(0, 2*10**5+1, 2):
        tmp = max((X-i//2)*A, 0) + i*C + max((Y-i//2)*B, 0)
        if ans ==-1 or ans > tmp:
            ans = tmp
    print(ans)
    
   
    
if __name__=='__main__':
    main()

Submission status: Accepted

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

# 購入金額
price_a_b = 0
price_mix = 0
price_c = 0

# Aピザ、BピザをそれぞれX,Y枚購入する
price_a_b = a*x + b*y

# ABピザを、MIN(X,Y)*2枚購入し、Aピザ、Bピザどちらかの不足分を購入する
price_mix = c*min(x, y)*2 + a*(x-min(x, y)) + b*(y-min(x, y))

# ABピザをMAX(X,Y)枚購入する
price_c = c*max(x, y)*2

print(min(price_a_b, price_mix, price_c))

Submission status: Accepted

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

minp=10**9+1
for i in range(X+1):
    p=0
    p+=A*i
    numab=(X-i)*2
    p+=numab*C
    p+=max(0,(Y-X+i))*B
    minp=min(minp,p)
for i in range(Y+1):
    p=0
    p+=B*i
    numab=(Y-i)*2
    p+=numab*C
    p+=max(0,(X-Y+i))*A
    minp=min(minp,p)
    
print(minp)

Submission status: Accepted

Solution code:
#ABC095_C
A,B,C,X,Y= map(int, input().split())
#AピザがA円、BピザがB円、ABのハーフハーフがC円。
#用意したいピザはAがX枚、BがY枚。
#Aピザをi枚買うとすると、ハーフハーフは2*(X-i)枚必要。
#このとき、Bピザの購入すべき枚数は

price_min = 1000000000
#初期値に注意する。どんどん安い値段が見つかるたびに更新したいのだから、
#初期値は十分大きくしておかないと、いつまでたっても最安値は更新されない

#Aピザをi枚買うとすると、iはi<=Xを満たす。
for i in range(X+1):
    #この時点ですでにBピザはX-i枚分ある。残りのピザをBピザとハーフピザで用意する。
    #この時点ですでにBピザが足りているなら、これ以上購入する必要はない。
    if Y <= X-i:
        price = i*A + 2*(X-i)*C
    #まだ足りないなら、残りY-（X-i）枚を用意する必要がある。
    #どちらを購入するかは、BとCの価格のうち、安いほうとすればよい。
    else:
        price = i*A + 2*(X-i)*C + min((Y-(X-i))*B,2*(Y-(X-i))*C)
    #print("Price now:", price)
    if price_min > price:
            #print("price_min",price_min,",price:",price)
            price_min = price
            #print("price_min changed to", price_min)
print(price_min)

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

Submission status: Accepted

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

Submission status: Accepted

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

    z = x - min(x, y)
    if z > 0:  # Aを買い足す必要あり
        ans += min(a * z, 2 * c * z)

    z = y - min(x, y)
    if z > 0:  # Bを買い足す必要あり
        ans += min(b * z, 2 * c * z)
    print(ans)

Submission status: Accepted

Solution code:
a, b, ab, x, y = (int(x) for x in input().split())
if x>y:
    tmp = x
    x = y
    y = tmp
    tmp = a
    a = b
    b = tmp

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

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
from decimal import *

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

ans = 0

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

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

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

print(ans)

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, tan, asin, acos, atan, radians, degrees#, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10**9 + 7
#from decimal import *

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

ans = []
ans.append(A*X + B*Y)
ans.append(C*(max(X, Y))*2)
if X > Y:
	ans.append(Y*C*2 + A*(X-Y))
else:
	ans.append(X*C*2 + B*(Y-X))

#print(ans)
print(min(ans))

Submission status: Accepted

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

ab_n = 2 * (max(x, y))
ans = float("inf")

for i in range(0, ab_n + 1, 2):
    a_n = x - i // 2
    b_n = y - i // 2
    if a_n < 0:
        a_n = 0
    if b_n < 0:
        b_n = 0
    ans = min(ans, a * a_n + b * b_n + c * i)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

print(min(tmp, a*x+b*y))