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

result = []

if X > Y:
    result.append(A * X + B * Y + C * 0)
    result.append(A * (X - Y) + B * 0 + C * 2 * min(X,Y))
    result.append(A * 0 + B * 0 + C * 2 * max(X,Y))
elif X < Y:
    result.append(A * X + B * Y + C * 0)
    result.append(A * 0 + B * ( Y - X ) + C * 2 * min(X,Y))
    result.append(A * 0 + B * 0 + C * 2 * max(X,Y))
else:
    result.append(A * X + B * Y + C * 0)
    result.append(A * 0 + B * 0 + C * 2 * max(X,Y))

print(min(result))

Submission status: Accepted

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

mast = max(x,y)
ans = float('INF')

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:



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

price = a * x + b * y


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

    price = min(price, cand)

print(price)

Submission status: Accepted

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

ans = 10 ** 9

for c in range(max(X, Y)+1):
    a = max(X - c, 0)
    b = max(Y - c, 0)

    cost = A * a + B * b + C * 2 * c
    ans = min(cost, ans)

print(ans)

Submission status: Accepted

Solution code:
def main():
    a, b, c, x, y = map(int, input().split())
    r = float('inf')
    for piza_c in range(0, max(x, y) * 2 + 1, 2):
        piza_a = max(0, x - piza_c // 2)
        piza_b = max(0, y - piza_c // 2)
        r = min(r, piza_c * c + piza_a * a + piza_b * b)
    print(r)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# coding: utf-8


def main():
    A, B, C, X, Y = map(int, input().split())
    ans = 0
    min_p = min(X, Y)
    d = X - Y

    if A + B > 2 * C:
        ans += 2 * C * min_p
    else:
        ans += (A + B) * min_p

    if d > 0:
        if A > 2 * C:
            ans += 2 * C * d
        else:
            ans += A * d
    elif d < 0:
        if B > 2 * C:
            ans += 2 * C * -d
        else:
            ans += B * -d

    print(ans)

if __name__ == "__main__":
    main()

Submission status: Accepted

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

else:
    ans = a*x+b*y
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
a, b, c, x, y = map(int, input().split(' '))
ans = float('inf')
c = c*2
for i in range(max(x, y)+1):
    if i > x:
        price = b*(y-i) + c*i
    elif i > y:
        price = a*(x-i) + c*i
    else:
        price = a*(x-i) + b*(y-i) + c*i

    if ans > price:
        ans = price
print(ans)

Submission status: Accepted

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

ans =0

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

Submission status: Accepted

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

ans = A*X+B*Y
price = 0
AB = 2*C

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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


moneys=[]
for i in range(0,max(x,y)*2+1,2):
    apizza=x-int(i/2)
    bpizza=y-int(i/2)
    if apizza<0:
        apizza=0
    if bpizza<0:
        bpizza=0
    money=apizza*a+bpizza*b+i*c
    moneys.append(money)

print(min(moneys))

Submission status: Accepted

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

price = 0

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

d = max(X, Y) - min(X, Y)
if d != 0:
    if X > Y:
        price += min(A, C * 2) * d
    else:
        price += min(B, C * 2) * d

print(price)

Submission status: Accepted

Solution code:
#!/usr/bin/python3
#coding: utf-8

A, B, C, X, Y = (int(x) for x in input().split())

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

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

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

print(ret)

Submission status: Accepted

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

Submission status: Accepted

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

ans = float("inf")

# 全部ミックスピザ
ans = min(2 * C * max(X, Y), ans)
# 普通に買う
ans = min(A * X + B * Y, ans)
# 多少はミックスも買う
if X >= Y:
    tmp = 2 * C * Y
    tmp += min((X - Y) * A, 2 * (X - Y) * C)
    ans = min(tmp, ans)
else:  # X < Y
    tmp = 2 * C * X
    tmp += min((Y - X) * B, 2 * (Y - X) * C)
    ans = min(tmp, ans)

print(ans)

Submission status: Accepted

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

mini = float('inf')

for i in range(10**6 + 1):
    calc = i * 2 * C + max(0, X - i) * A + max(0, Y - i) * B
    if calc < mini:
        mini = calc

print(mini)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

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

if 2 * c >= a + b:
    print(a * x + b * y)
    sys.exit(0)

ans = 0
_min = min(x, y)
ans += (2 * c) * _min
x -= _min
y -= _min
if x != 0:
    ans += x * min(a, 2 * c)
    pass
if y != 0:
    ans += y * min(b, 2 * c)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(1,1+2*max(X,Y)):
  if X-i/2<0:
    a=0
  else:
    a=X-i/2
  if Y-i/2<0:
    b=0
  else:
    b=Y-i/2
  ans = min(ans, A*a+B*b+C*i)
  
print(int(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=C*2*X
    if 2*C<=B:
      ans+=2*C*(Y-X)
    else:
      ans+=B*(Y-X)
  else:
    ans=C*2*Y
    if 2*C<=A:
      ans+=2*C*(X-Y)
    else:
      ans+=A*(X-Y)
print(ans)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

def II(): return int(input())
def MII(): return map(int, input().split())
def LII(): return list(map(int, input().split()))

def main():
    A, B, C, X, Y = MII()

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

    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline
a, b, c, x, y= map(int, input().split())
ab = 2*c
count_x = 0
count_y = 0
buy_a = 0
buy_b = 0
buy_c = 0

if ab < a+b:
    min_count = min(x,y)
    count_x = min_count
    count_y = min_count
    buy_c = 2*min_count
    if x - count_x > 0:
        if ab > a:
            buy_a += x - count_x
        else:
            buy_c += 2 * (x - count_x)
    
    elif y - count_y > 0:
        if ab > b:
            buy_b += y - count_y
        else:
            buy_c += 2*(y - count_y)
else:
    min_count = min(x,y)
    if min_count == x:
        buy_a = min_count
        if ab > b:
            buy_b += y
        else:
            buy_c += 2 * y
    else:
        buy_b = min_count
        if ab > a:
            buy_a += x
        else:
            buy_c += 2 * x

print(buy_a * a + buy_b * b + buy_c * c)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
a, b, c, x, y = list(map(int, input().split()))
INF = float("inf")
ans = INF
for ab in range(max(x, y)*2+1):
    if ab % 2 == 0:
        ans = min(ans, ab*c + max(x-ab//2, 0)*a + max(y-ab//2, 0)*b)
print(ans)

Submission status: Accepted

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

c *= 2
t = 0

if a+b > c:
  v = min([x,y])
  t = v * c
  x, y = x-v, y-v

  if x>0:
    if a<c:
      t = t + a*x
    else:
      t = t + c*x
  elif y>0:
    if b<c:
      t = t + b*y
    else:
      t = t + c*y
else:
  t = a*x + b*y

print(t)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A,B,C,X,Y=map(int,input().split())
ABset = 2*C
gokei = A*X+B*Y
for i in range(0,max(X+1,Y+1)):
    ABdai = i*ABset
    Adai = A*(X-i)
    if X<i:
        Adai = 0
    Bdai = B*(Y-i)
    if Y<i:
        Bdai = 0
    gokei = min(gokei,ABdai+Adai+Bdai)
print(gokei)

Submission status: Accepted

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

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

Submission status: Accepted

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

ans1 = x * a + y * b

min_xy = min(x, y)
ans2 = min_xy * 2 * c + (x - min_xy) * a + (y - min_xy) * b

max_xy = max(x, y)
ans3 = max_xy * 2 * c

print(min(ans1, ans2, ans3))

Submission status: Accepted

Solution code:
import sys
def MI(): return map(int,sys.stdin.readline().rstrip().split())


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

ans = 10**18
for i in range(0,2*max(X,Y)+1,2):  # i:ABピザを買う枚数
    ans = min(ans,A*max(0,X-i//2)+B*max(0,Y-i//2)+C*i)

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))

INF=10**20
def main():
    A,B,C,X,Y = mi()

    ans = INF
    for z in range(10**6):
        x = max(0,X-z//2)
        y = max(0,Y-z//2)

        ans = min(A*x+B*y+C*z,ans)
    
    print(ans)




if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
A, B, C, X, Y = map(int, input().split())
ans = 0
if A + B >= 2 * C:
  ans += 2 * C * min(X, Y)
  if X > Y:
    if A > 2 * C:
      ans += 2 * C * (X - Y)
    else:
      ans += A * (X - Y)
  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())
p = a*x + b*y
q = 2*c*max(x,y)
r = 2*c*x + b*(y-x)
s = 2*c*y + a*(x-y)
if x >=y:
        print(min(p,q,s))
else:
        print(min(p,q,r))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import math

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

min_sum = A*X+B*Y
for c in range(0, (max(X, Y)*2)+1, 2):
    s = (max(X-math.floor(c/2), 0))*A + (max(Y-math.floor(c/2), 0))*B + c*C
    if s < min_sum:
        min_sum = s
print(min_sum)

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

res = float("inf")

for i in range(0, max(X, Y) * 2 + 1, 2):
    Amai = max(0, X - i // 2)
    Bmai = max(0, Y - i // 2)
    res = min(res, A * Amai + B * Bmai + C * i)

print(res)

Submission status: Accepted

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

Submission status: Accepted

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

if __name__ == "__main__":
    solve()

Submission status: Accepted

Solution code:
# row = [int(x) for x in input().rstrip().split(" ")]
# n = int(input().rstrip())
# s = input().rstrip()

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

    a, b, c, x, y = [int(x) for x in input().rstrip().split(" ")]

    a_count = 0
    b_count = 0
    ab_count = 0
    if a + b > 2 * c:
        # abのが割安なら、買えるだけabを買う
        min_pizza = min(x,y)
        ab_count += min_pizza * 2
        x = x - min_pizza
        y = y - min_pizza

    # aを買う
    if c * 2 < a:
        # abでaを用意した方が安いなら
        ab_count += x * 2
    else:
        # aでaを買う
        a_count += x

    # bを買う
    if c * 2 < b:
        # abでbを用意した方が安いなら
        ab_count += y * 2
    else:
        # aでaを買う
        b_count += y

    print(a_count * a + b_count * b + ab_count * c)


if __name__ == "__main__":
    resolve()

Submission status: Accepted

Solution code:

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

ans = x*a + y*b # normal

ans = min(ans, 2*c*max(x, y)) # all from c


if max(x, y) == x: 
    A = True
else:
    A = False
left = (max(x, y) - min(x, y))*(a if A else b)
ans = min(ans, 2*c*min(x, y) + left)

print(ans)

Submission status: Accepted

Solution code:
# 与えられた数値の桁数と桁値の総和を計算する.
def calc_digit_sum(num):
    digits = sums = 0
    while num > 0:
        digits += 1
        sums += num % 10
        num //= 10
    return digits, sums


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

min_v = min(x, y)
max_v = max(x, y)

candidate1 = (a * x) + (b * y)
candidate2 = c * (max_v * 2)
candidate3 = c * (min_v * 2) + (a * (max_v - min_v) if max_v == x else b * (max_v - min_v))

print(min(candidate1, candidate2, candidate3))

Submission status: Accepted

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

ans = float("inf")

if X > Y:
    ab = 2 * X
    while ab >= 0:
        a = X - (ab / 2)
        if ab / 2 < Y:
            b = int(Y - ab / 2)
        else:
            b = 0
        money = a * A + b * B + ab * C
        ans = min(ans, money)
        ab -= 2
else:
    ab = 2 * Y
    while ab >= 0:
        b = Y - (ab / 2)
        if ab / 2 < X:
            a = int(X - ab / 2)
        else:
            a = 0
        money = a * A + b * B + ab * C
        ans = min(ans, money)
        ab -= 2
print(int(ans))

Submission status: Accepted

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

res = 0

is_lower_a = True
if X > Y:
    is_lower_a = False

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
A,B,C,X,Y = list(map(int,input().split()))
out = 10**9
L = []
L.append(A*X+B*Y)
L.append(C*2*max(X,Y))
if X<Y:
    L.append(C*2*X+B*(Y-X))
if X>Y:
    L.append(C*2*Y+A*(X-Y))
print(min(L))

Submission status: Accepted

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

Submission status: Accepted

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

answer = 7000000000
for i in range(100001):
  amount = i*2*c + max(0, x-i)*a + max(0, y-i)*b
  if answer > amount:
    answer = amount
print(answer)

Submission status: Accepted

Solution code:
def i():
	return int(input())
def i2():
	return map(int,input().split())
def s():
	return str(input())
def l():
	return list(input())
def intl():
	return list(int(k) for k in input().split())

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

ans = float("inf")
note = 0
for i in range(0,2*max(x,y)+1,2):
	note = a*max(0,x-i//2)+b*max(0,y-i//2)+c*i
	ans = min(ans,note)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import math
import numpy as np
def I():return int(sys.stdin.readline().replace("\n",""))
def I2():return map(int,sys.stdin.readline().replace("\n","").split())
def S():return str(sys.stdin.readline().replace("\n",""))
def L():return list(sys.stdin.readline().replace("\n",""))
def Intl():return [int(k) for k in sys.stdin.readline().replace("\n","").split()]
def Lx(k):return list(map(lambda x:int(x)*-k,sys.stdin.readline().replace("\n","").split()))

if __name__ == "__main__":
    a, b, c, x, y = I2()
    ans = float("inf")
    for i in range(2*max(x,y)+1):
        cost = c * i + a * max(0,x - i // 2) + b * max(0,y - i // 2)
        ans = min(cost,ans)
    print(ans)

Submission status: Accepted

Solution code:
# coding: utf-8
A,B,C,X,Y = map(int, input().split())
minprice = 10**10
for i in range(max(X,Y)+1):
    tmp = 0
    tmp += C * i*2
    tmp += A * max(0,X-i)
    tmp += B * max(0,Y-i)
    minprice = min(minprice, tmp)
print(minprice)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

#全部AとBで用意
ans = A * X + B * Y

if X > Y:
  X, Y = Y, X
  A, B = B, A

#全部ABで用意
ans = min(ans, Y * C * 2)

#少ないほうだけABで用意
ans = min(ans, X * C * 2 + (Y - X) * B)

print(ans)

Submission status: Accepted

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

for i in range(0, max(x, y) * 2 + 1, 2):
    d = x - i // 2
    e = y - i // 2
    if d < 0 :
        d = 0
    if e < 0:
        e = 0
    sum = a * d + b * e + c * i
    
    if min_sum > sum :
        min_sum = sum

print(min_sum)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    a, b, c, x, y = (int(i) for i in input().split())
    ans1 = a * x + b * y
    ans2 = -1
    if x < y:
        ans2 = 2 * c * x + b * (y - x)
    else:
        ans2 = 2 * c * y + a * (x - y)
    ans3 = 2 * c * max(x, y)
    print(min(ans1, ans2, ans3))


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

ans = 10**18
for i in range(max(X,Y)+1):
    cost = i * AB
    if i < X:
        cost += A * (X-i)
    if i < Y:
        cost += B * (Y-i)
    ans = min(ans, cost)

print(ans)

Submission status: Accepted

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

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

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

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

print(ans)

Submission status: Accepted

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

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

print(min(P))

Submission status: Accepted

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

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

print(amount)

Submission status: Accepted

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

Submission status: Accepted

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

p1 = a * x + b * y
# A>C
p = c * 2 * x

if x >= y:
  p = p

else:
  p = p + (y - x) * b
      
# B>C
p2 = c * 2 * y
if x >= y:
  p2 = p2 + (x - y) * a
else:
  p2 =p2
  
print(min(p, p1, p2))

Submission status: Accepted

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

answer = 10 ** 18
for c in range(10 ** 5 + 1):
    a = X - c
    b = Y - c
    cost = C * c * 2
    cost += max(a, 0) * A
    cost += max(b, 0) * B
    if answer > cost:
        answer = cost
print(answer)

Submission status: Accepted

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

cost1 = a * x + b * y
cost2 = c * max(x, y) * 2
if x < y:
    cost3 = c * x * 2 + b * (y - x)
else:
    cost3 = c * y * 2 + a * (x - y)
print(min(cost1, cost2, cost3))

Submission status: Accepted

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

cost_1 = A*X + B*Y
cost_2 = C * max(X, Y) * 2

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


print(min(cost_1, cost_2, cost_3))

Submission status: Accepted

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

ans=A*X+B*Y
Z=0
while max(X,Y)*2>=Z:
    x=max(0,X-(Z//2))
    y=max(0,Y-(Z//2))
    ans=min(ans,A*x+B*y+C*Z)
    Z+=2
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a, b, c, x, y = map(int, input().split())
# print(f"{a} {b} {c} {x} {y}")

ax = a * x
by = b * y

# print(f"{ax}")
# print(f"{by}")

cxy = c * (2 * (max(x, y)))
# print(f"{cxy}")

c_maisu_max = 2 * (max(x, y))
# print(f"{c_maisu_max}")

ans = 9999999999
for c_maisu in range(c_maisu_max, -1, -2):
    kingaku = 0
    if c_maisu // 2 >= max(x, y):
        kingaku = c * c_maisu
        # print(kingaku)
    else:
        a_maisu = 0
        b_maisu = 0
        # print(x - (c_maisu // 2))
        # print(y - (c_maisu // 2))
        if x - (c_maisu // 2) > 0:
            a_maisu = x - (c_maisu // 2)
        if y - (c_maisu // 2) > 0:
            b_maisu = y - (c_maisu // 2)
            
        kingaku = (a * a_maisu) + (b * b_maisu) + (c * c_maisu)
        
        # print(kingaku)
        
    ans = min(ans, kingaku)
    
print(ans)

Submission status: Accepted

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

z=min(X,Y)
x=X-z
y=Y-z
ans=min(ans,x*A+y*B+C*2*z)

z=max(X,Y)
ans=min(ans,C*2*z)
print(ans)

Submission status: Accepted

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

answer_1 = A * X + B * Y # すべてA、Bで買う場合
answer_2 = C * 2 * max(X, Y) # すべてCで買う場合

# answer_3: 先にA,Bを買ってからあまりをCで補う場合
# answer_4: 先にCを買ってから最後に残りA,Bで補う場合
if X > Y:
    answer_3 = A * Y + B * Y + C * (X - Y) * 2
    answer_4 = A * (X - Y) + C * Y * 2
else:
    answer_3 = A * X + B * X + C * (Y - X) * 2
    answer_4 = B * (Y - X) + C * X * 2

answer = min(answer_1, answer_2, answer_3, answer_4)
print(answer)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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