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: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import sys

input = sys.stdin.readline


def main():
    A, B, C, X, Y = [int(x) for x in input().split()]
    ans = []
    ans.append(A * X + B * Y)
    ans.append(C * 2 * (max(X, Y)))
    if X > Y:
        ans.append(C * 2 * Y + (X - Y) * A)
    else:
        ans.append(C * 2 * Y + (Y - X) * B)

    print(min(ans))


    

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

m = 1000000000000
for i in range(max(x, y)*2):
    total = a*(max(0, x-i//2)) + b*(max(0, y-i//2)) + c*i
    if total < m:
        m = total

print(m)

Submission status: Wrong Answer

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

m = 100000000
for i in range(max(x, y)*2):
    total = a*(max(0, x-i//2)) + b*(max(0, y-i//2)) + c*i
    if total < m:
        m = total

print(m)

Submission status: Wrong Answer

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

chp = min(a+b,c*2)
memo1 = min(x,y)
memo2 = max(x,y)-min(x,y)
if x>y:
    print(memo2*a+memo1*chp)
else:
    print(memo2*b+memo1*chp)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

c1=a*x+b*y
if x>=y:
    c2=2*y*c+(x-y)*x
else:
    c2=2*x*c+(y-x)*y
c3=2*max(x,y)*c
print(min(c1,c2,c3))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

min = float('inf')
for k in range(10**5):
    temp = 2*C*k+max(X-k,0)*A+max(Y-k,0)*B

    if min > temp:
        min = temp
print(min)

Submission status: Wrong Answer

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

n = min(X,Y)

sum = 0

sum = min(n*2*C, A*n+B*n)

if X>Y:
    n = X-n
    sum = sum + n*A
else:
    n = Y - n
    sum = sum + n*B

sum_ab = X*A + Y*B

sum_a_b = 2*(X+Y)*C


print(min(sum,sum_ab,sum_a_b))

Submission status: Wrong Answer

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

n = min(X,Y)

sum = 0

sum = min(n*2*C, A*n+B*n)

if X>Y:
    n = X-n
    sum = sum + n*A
else:
    n = Y - n
    sum = sum + n*B

s = (X+Y)*2*C

if sum>s:
    print(s)
else:
    print(sum)

Submission status: Wrong Answer

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

n = min(X,Y)

sum = 0

sum = min(n*2*C, A*n+B*n)

if X>Y:
    n = X-n
    sum = sum + n*A
else:
    n = Y - n
    sum = sum + n*B

print(sum)

s = (X+Y)*2*C

if sum>s:
    print(s)
else:
    print(sum)

Submission status: Wrong Answer

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

n = min(X,Y)

sum = 0

sum = min(n*2*C, A*n+B*n)

if X>Y:
    n = X-n
    sum = sum + n*A
elif X < Y:
    n = Y - n
    sum = sum + n*B

print(sum)

Submission status: Wrong Answer

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

n = min(X,Y)

sum = 0

sum = min(n*2*C, A*n+B*n)

if X>Y:
    n = X-n
    sum = sum + n*A
else:
    n = Y - n
    sum = sum + n*B

print(sum)

Submission status: Wrong Answer

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

if a+b>2*c:
  if x>=y: #aが多い
    if a>=2*c:
      print(x*c*2)
    else:
      print(y*c*2+(x-y)*a)
  else:
    if b>=2*c:
      print(y*b*2)
    else:
      print(x*c*2+(y-x)*a)
else:
  print(a*x+b*y)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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

pi = {'A':A, 'B':B, 'C':C}
buy = {'A':X, 'B':Y}
if X < Y:
	low, high = 'A','B'
else:
	low, high = 'B','A'

ans=0
if A+B >= 2*C:
	if A >= 2*C and B >= 2*C:
		ans+=(2*C)*buy[high]
	else:
		ans += (2*C)*buy[low] + (pi[high])*(buy[high]-buy[low])
else:
	ans = A*X + B*Y

print(ans)

Submission status: Wrong Answer

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

pi = {'A':A, 'B':B, 'C':C}
buy = {'A':X, 'B':Y}
if X < Y:
	low, high = 'A','B'
else:
	low, high = 'B','A'

ans=0
if A+B >= 2*C:
	if A >= C and B >= C:
		ans+=(2*C)*buy[high]
	else:
		ans += (2*C)*buy[low] + (pi[high])*(buy[high]-buy[low])
else:
	ans = A*X + B*Y

print(ans)

Submission status: Wrong Answer

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

pi = {'A':A, 'B':B, 'C':C}
buy = {'A':X, 'B':Y}
if X < Y:
	low, high = 'A','B'
else:
	low, high = 'B','A'

ans=0
if A+B >= 2*C:
	if A >= C and B >= C:
		ans+=(2*C)*buy[high]
	else:
		ans += (2*C)*buy[low] + (pi[high])*(buy[high]-buy[low])
elif A <= 2*C and B <= 2*C:
	ans = A*X + B*Y
elif A > 2*C:
	ans = (2*C)*X + B*Y
else:
	ans = A*X + (2*C)*Y

print(ans)

Submission status: Wrong Answer

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

ans = 0
for i in range(1, max(X,Y)+1):
    x = 1
    y = 1
    if X == 0: x = 0
    if Y == 0: y = 0
    ab_price = A * x + B * y
    c_price = C * 2
    # print(X,Y, x, y, ab_price, c_price)
    if ab_price > c_price:
        ans += C * 2
    else:
        _x = 0
        if x > 0:
          _x = 1
        _y = 0
        if y > 0:
          _y = 1
        ans += A * _x + B * _y
    X -= 1
    Y -= 1
print(ans)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
input = sys.stdin.readline

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

min_cost = 5000 * 100000
#abピザを2i枚買う時残り必要な額を計算する

for i in range(100001):
    zan_a = max(x-i,0)
    zan_b = max(y-i,0)
    min_cost = min((a*zan_a+b*zan_b+c*i*2),min_cost)
print(min_cost)

Submission status: Wrong Answer

Solution code:
A,B,AB,X,Y=map(int,input().split())
ANS=0
if A + B >= AB * 2:
  if min(X,Y) == X:
    # X < Y
    ANS = AB * X * 2
    R = Y - X if Y - X > 0 else 0
   
    if B <= AB * 2:
      ANS += B * R
    else:
      ANS += AB * 2 * R
  else:
    # X > Y
    ANS = AB * Y * 2 if Y - X > 0 else 0
    R = X - Y
    if A <= AB * 2:
      ANS += A * R
    else:
      ANS += AB * 2 * R
else:
  ANS = A * X + B * Y
print(ANS)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if A > C and B > C:
    print(max(A, B) * C)
else:

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

        else:
            if X > Y:
                print(C*Y * 2 + (X - Y) * A)

            else:
                print(C*X * 2 + (Y - X) * B)

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

Submission status: Wrong Answer

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

if A + B > C:
    print(max(A, B) * C)
else:

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

        else:
            if X > Y:
                print(C*Y * 2 + (X - Y) * A)

            else:
                print(C*X * 2 + (Y - X) * B)

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

Submission status: Wrong Answer

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


def solve(A: int, B: int, C: int, X: int, Y: int):
    ans = 10**9
    if Y > X:
        bigger_y = 1
        bigger_x = 0
    elif Y == X:
        bigger_y = 1
        bigger_x = 1
    else:
        bigger_y = 0
        bigger_x = 1

    if A + B < 2 * C:#C=0
        ans = A*X + B*Y
    else:#C>1
        #Aを2*Cで補うときの利益 > Bを2*Cで補うときの利益
        if A*X - 2*C*X + B*(Y-X)*bigger_y > B*Y - 2*C*Y + A*(Y-X)*bigger_x:
            #A=0
            if bigger_x:
                ans = 2*C*X
            else:
                ans = 2*C*X + (Y-X)*B

        #Aを2*Cで補うときの利益 < Bを2*Cで補うときの利益
        else:
            #B=0
            if bigger_y:
                ans = 2*C*Y
            else:
                ans = 2*C*Y + (X-Y)*A
        if 2*C < A and 2*C < B:
            ans = min(ans, 2*C*max(X,Y))
    print(ans)

# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    X = int(next(tokens))  # type: int
    Y = int(next(tokens))  # type: int
    solve(A, B, C, X, Y)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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


def solve(A: int, B: int, C: int, X: int, Y: int):
    ans = 10**9
    if Y > X:
        bigger_y = 1
        bigger_x = 0
    elif Y == X:
        bigger_y = 1
        bigger_x = 1
    else:
        bigger_y = 0
        bigger_x = 1

    if A + B < 2 * C:#C=0
        ans = A*X + B*Y
    else:#C>1
        #Aを2*Cで補うときの利益 > Bを2*Cで補うときの利益
        if A*X - 2*C*X + B*X*bigger_y > B*Y - 2*C*Y + A*Y*bigger_x:
            #A=0
            if bigger_x:
                ans = 2*C*X
            else:
                ans = 2*C*X + (Y-X)*B

        #Aを2*Cで補うときの利益 < Bを2*Cで補うときの利益
        else:
            #B=0
            if bigger_y:
                ans = 2*C*Y
            else:
                ans = 2*C*Y + (X-Y)*A
        if 2*C < A and 2*C < B:
            ans = min(ans, 2*C*max(X,Y))
    print(ans)

# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    X = int(next(tokens))  # type: int
    Y = int(next(tokens))  # type: int
    solve(A, B, C, X, Y)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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


def solve(A: int, B: int, C: int, X: int, Y: int):
    ans = 10**9
    if Y > X:
        bigger_y = 1
        bigger_x = 0
    elif Y == X:
        bigger_y = 0
        bigger_x = 0
    else:
        bigger_y = 0
        bigger_x = 1

    if A + B < 2 * C:#C=0
        ans = A*X + B*Y
    else:#C>1
        #Aを2*Cで補うときの利益 > Bを2*Cで補うときの利益
        if A*X - 2*C*X + B*X*bigger_y > B*Y - 2*C*Y + A*Y*bigger_x:
            #A=0
            if bigger_x:
                ans = 2*C*X
            else:
                ans = 2*C*X + (Y-X)*B

        #Aを2*Cで補うときの利益 < Bを2*Cで補うときの利益
        else:
            #B=0
            if bigger_y:
                ans = 2*C*Y
            else:
                ans = 2*C*Y + (X-Y)*A
        if 2*C < A and 2*C < B:
            ans = min(ans, 2*C*max(X,Y))
    print(ans)

# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    X = int(next(tokens))  # type: int
    Y = int(next(tokens))  # type: int
    solve(A, B, C, X, Y)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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


def solve(A: int, B: int, C: int, X: int, Y: int):
    ans = 0
    if Y > X:
        bigger_y = 1
        bigger_x = 0
    elif Y == X:
        bigger_y = 0
        bigger_x = 0
    else:
        bigger_y = 0
        bigger_x = 1

    if A + B < 2 * C:#C=0
        ans = A*X + B*Y
    else:#C>1
        #Aを2*Cで補うときの利益 > Bを2*Cで補うときの利益
        if A*X - 2*C*X + B*X*bigger_y > B*Y - 2*C*Y + A*Y*bigger_x:
            #A=0
            if bigger_x:
                ans = 2*C*X
            else:
                ans = 2*C*X + (Y-X)*B

        #Aを2*Cで補うときの利益 < Bを2*Cで補うときの利益
        else:
            #B=0
            if bigger_y:
                ans = 2*C*Y
            else:
                ans = 2*C*Y + (X-Y)*A
        if 2*C < A and 2*C < B:
            ans = 2*C*max(X,Y)
    print(ans)

# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    X = int(next(tokens))  # type: int
    Y = int(next(tokens))  # type: int
    solve(A, B, C, X, Y)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
A, B, C, X, Y = list(map(int, input().split()))
ans = 10**20
for nc in range(0, max(X,Y)*2+1, 2):
    na = X-nc//2
    nb = Y-nc//2
    ans = min(ans, na*A+nb*B+nc*C)
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

# Cを買わない場合
ans1 = A * X + B * Y

# Cを余りが出ないように最大まで買う場合
ans2 = C * 2 * min(X, Y) + A * (X - min(X, Y)) + B * Y * (Y - min(X, Y))

# Cのみ買う場合
ans3 = C * 2 * max(X, Y)

ans = min(ans1, ans2, ans3)
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

C = c*2
ans = []
if C<a+b:
    if x>y:
        ans.append(C*x)
        ans.append(C*y+a*(x-y))
    else:
        ans.append(C*y)
        ans.append(C*x+a*(y-x))
else:
    ans.append(a*x+b*y)
print(min(ans))

Submission status: Wrong Answer

Solution code:
a,b,c,x,y=map(int,input().split())
lo=0 
hi=10**19
def check(mi): 
    m=max(x,y)
    if m*2*c<=mi:
        #print('sdfu')
        return 1 
    if a<c and b<c: 
        cost=a*x+b*y 
        #print('hf')
        return cost<=mi 
    if a>c and b>c:
        cost=0 
        mini=min(x,y)
        #print('hsdfiu')
        return mini*c*2+(-mini+x)*a+(-mini+y)*b<=mi 

    if a*x+b*y<=mi:
        return 1 
    mini=min(x,y)
    if mini*c*2+(x-mini)*a+(y-mini)*b<=mi:
        print('sf')
        return 1 
    return 0 
#print(check(1700))
#print(check(4700))
#print(check(100000000))
while lo<=hi:
    mi=(lo+hi)>>1 
    if check(mi):
        ans=mi 
        hi=mi-1 
    else:
        lo=mi+1 
print(ans)

Submission status: Wrong Answer

Solution code:
a,b,c,x,y=map(int,input().split())
lo=0 
hi=10**19
def check(mi): 
    if a<c and b<c: 
        cost=a*x+b*y 
        #print('hf')
        return cost<=mi 
    if a>c and b>c:
        cost=0 
        mini=min(x,y)
        #print('hsdfiu')
        return mini*c*2+(-mini+x)*a+(-mini+y)*b<=mi 
    m=max(a,b)
    if m*2*c<=mi:
        #print('sdfu')
        return 1 
    if a*x+b*y<=mi:
        return 1 
    mini=min(x,y)
    if mini*c*2+(x-mini)*a+(y-mini)*b<=mi:
        print('sf')
        return 1 
    return 0 
#print(check(1700))
#print(check(4700))

while lo<=hi:
    mi=(lo+hi)>>1 
    if check(mi):
        ans=mi 
        hi=mi-1 
    else:
        lo=mi+1 
print(ans)

Submission status: Wrong Answer

Solution code:
a,b,c,x,y=map(int,input().split())
m=min(x,y)
if a/2+b/2>c : 
   cost=0 
   cost=m*c*2 
  # print(cost)
   cost+=(x-m)*a+(y-m)*b  
   print(cost)
   exit()
print(a*x+b*y)
exit()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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


def main():
    import math
    import collections
    import itertools

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



if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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


def main():
    import math
    import collections
    import itertools

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



if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

res=0

if X > 0: # buy some A pizza
        if A > 2 * C: # buy 2X * AB pizza
                res += C * 2*X
                Y -= X
        else: # buy A pizza
                res += X * A

if Y > 0: # buy some B pizza
        if B > 2 * C:
                res += C*2*Y
        else:
                res+= Y * B

print(res)

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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

if A > C * 2 and B > C * 2:
    ans = C * 2 * max(X, Y)

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

else:
    ans = A * X + B * Y

print(ans)

Submission status: Wrong Answer

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

if A > C and B > C:
    ans = C * 2 * max(X, Y)

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

else:
    ans = A * X + B * Y

print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
A,B,C,X,Y = map(int,input().split())
ans = 0
while (X + Y) > 0:
    if X >= 2 and Y >= 2:
        num = min(X//2,Y//2)
        ans += min((A+B),C*2) * 2 * num
        X -= 2 * num
        Y -= 2 * num
    elif X == 1 and Y >= 2:
        if B < C*2:
            ans += B*Y
            Y = 0
        else:
            num = Y // 2
            ans += C*2*num
            Y -= 2*num
            X = 0
    elif Y == 1 and X >= 2:
        if A < C*2:
            ans += A*X
            X = 0
        else:
            num = X // 2
            ans += C*2*num
            X -= 2*num
            Y = 0
    elif X == 1 and Y == 1:
        ans += min(A+B, C*2)
        X -= 1
        Y -= 1
    elif X == 0:
        ans += Y * min(B,C*2)
        Y = 0
    elif Y == 0:
        ans += X * min(A,C*2)
        X = 0

print(ans)

Submission status: Wrong Answer

Solution code:
A,B,C,X,Y = map(int,input().split())
ans = 0
while (X + Y) > 0:
    if X >= 2 and Y >= 2:
        num = min(X//2,Y//2)
        ans += min((A+B),C*2) * 2 * num
        X -= 2 * num
        Y -= 2 * num
    elif X == 1 and Y >= 2:
        if A < C*2:
            ans += A
            X -= 1
        else:
            ans += C*2
            X -= 1
            Y -= 1
    elif Y == 1 and X >= 2:
        if B < C*2:
            ans += B
            Y -= 1
        else:
            ans += C*2
            X -= 1
            Y -= 1
    elif X == 1 and Y == 1:
        ans += min(A+B, C*2)
        X -= 1
        Y -= 1
    elif X == 0:
        ans += Y * min(B,C*2)
        Y = 0
    elif Y == 0:
        ans += X * min(A,C*2)
        X = 0

print(ans)

Submission status: Wrong Answer

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

tmp1 = c * min(x, y) * 2
tmp2 = min(a, b) * abs(x - y)

pattern1 = (a * x + b * y)
pattern2 = tmp1 + tmp2
pattern3 = c * max(x, y) * 2

print(min(pattern1, pattern2, pattern3))