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())
c = c*2
n = max(x,y)
ans = 10**25
for i in range(10**6):
    x1,y1 = i,i
    p = c*i
    if x > x1:
        if y > y1:
            p += a*(x-x1) + b*(y-y1)
        else:
            p += a*(x-x1)
    else:
        if y > y1:
            p += b*(y+y1)
    if ans > p:
        ans = p

print(ans)

Submission status: Wrong Answer

Solution code:
a,b,c,x,y = map(int,input().split())
c = c*2
n = max(x,y)
ans = 10**25
for i in range(10**5):
    x1,y1 = i,i
    p = c*i
    if x > x1:
        if y > y1:
            p += a*(x-x1) + b*(y-y1)
        else:
            p += a*(x-x1)
    else:
        if y > y1:
            p += b*(y+y1)
    if ans > p:
        ans = p

print(ans)

Submission status: Wrong Answer

Solution code:
a,b,c,x,y = map(int,input().split())
c = c*2
n = max(x,y)
ans = 10**25
for i in range(n*2):
    x1,y1 = i,i
    p = c*i
    if x > x1:
        if y > y1:
            p += a*(x-x1) + b*(y-y1)
        else:
            p += a*(x-x1)
    else:
        if y > y1:
            p += b*(y+y1)
    if ans > p:
        ans = p

print(ans)

Submission status: Wrong Answer

Solution code:
a,b,c,x,y = map(int,input().split())
c = c*2
n = max(x,y)
ans = 10**25
for i in range(n+1):
    x1,y1 = i,i
    p = c*i
    if x > x1:
        if y > y1:
            p += a*(x-x1) + b*(y-y1)
        else:
            p += a*(x-x1)
    else:
        if y > y1:
            p += b*(y+y1)
    if ans > p:
        ans = p

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:

A,B,C,X,Y = list(map(int,input().split()))
max_pizza=max(X,Y)#AピザとBピザのうち、必要な枚数の多い方のピザの枚数
ans=10E+10  

for i in range(0,max_pizza*2,2):#ABピザをi枚買う(iは偶数)
    
    if (X-i/2)<=0 and (Y-i/2)>0:
        ans_kouho = B*(Y-i/2)+C*(i)
    elif (X-i/2)>0 and(Y-i/2)<=0:
        ans_kouho = A*(X-i/2)+C*(i)
    elif (X-i/2)<=0 and(Y-i/2)<=0:
         ans_kouho = C*(i)
    else:
        ans_kouho = A*(X-i/2)+B*(Y-i/2)+C*(i)

    
    if(ans_kouho<ans):
        ans = ans_kouho

print(int(ans))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

for i in range(2, max(X, Y)*2, 2):
  total = A*(X-(i/2)) + B*(Y-(i/2)) + C*i
  ans = min(ans, total)
  
print(int(ans))

Submission status: Wrong Answer

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

price = 0

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


print(price)

Submission status: Wrong Answer

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

ans = float("inf")
for i in range(max(X, Y)):
    x = max(X - i, 0)
    y = max(Y - i, 0)
    cost = 2*C * i + A * x + B * y
    ans = min(ans, cost)

print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

ans=[]

ans.append(A*X+B*Y)
ans.append(C*max(X,Y)*2)

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

print(min(ans))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def printlist(lst, k='\n'): print(k.join(list(map(str, lst))))
INF = float('inf')

def solve():
    a, b, c, x, y = MI()

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

        if x < y:
            x = y

        if a > 2*c:
            ans += x * 2 * c
        else:
            ans += x * a

    else:
        mn = min(x, y)
        ans = mn * 2 * c
        x -= mn
        y -= mn

        if x < y:
            x = y

        if a > 2 * c:
            ans += x * 2 * c
        else:
            ans += x * a

    print(ans)



if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

Solution code:
A, B, AB, X, Y = map(int, input().split())
max_price = A * X + B * Y
flag = 1
mid_price = (A + B) // 2
if A > AB and B > AB:
    min_sheet = max(X, Y)
else:
    min_sheet = min(X, Y)

price = max_price + 1

while flag:
    flag = 0
    if AB <= mid_price:
        price = min_sheet * AB * 2
        X -= min_sheet
        Y -= min_sheet
    if X < 1 and Y < 1:
        break
    elif X > 0:
        price += X * A
        if Y > 0:
            price += Y * B
    elif Y > 0:
        price += Y * B
        if X > 0:
            price += X * A

print(min(max_price, price))

Submission status: Wrong Answer

Solution code:
A, B, AB, X, Y = map(int, input().split())
max_price = A * X + B * Y
flag = 1
mid_price = (A + B) // 2
if A > AB and B > AB:
    min_sheet = max(X, Y)
else:
    min_sheet = min(X, Y)

price = max_price + 1

while flag:
    flag = 0
    if AB < mid_price:
        price = min_sheet * AB * 2
        X -= min_sheet
        Y -= min_sheet
    if X < 1 and Y < 1:
        break
    elif X > 0:
        price += X * A
        if Y > 0:
            price += Y * B
    elif Y > 0:
        price += Y * B
        if X > 0:
            price += X * A

print(min(max_price, price))

Submission status: Wrong Answer

Solution code:
A, B, AB, X, Y = map(int, input().split())
max_price = A * X + B * Y
flag = 1
mid_price = (A + B) // 2
if A >= AB and B >= AB:
    min_sheet = max(X, Y)
else:
    min_sheet = min(X, Y)

price = max_price + 1

while flag:
    flag = 0
    if AB <= mid_price:
        price = min_sheet * AB * 2
        X -= min_sheet
        Y -= min_sheet
    if X < 1 and Y < 1:
        break
    elif X > 0:
        price += X * A
        if Y > 0:
            price += Y * B
    elif Y > 0:
        price += Y * B
        if X > 0:
            price += X * A

print(min(max_price, price))

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

Submission status: Wrong Answer

Solution code:
import itertools
a,b,c,x,y = map(int, input().split(" "))
ans = 10 ** 11

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

else:
  for i in range(min(x, y) + 1):
    temp = a * (x - i) + b * (y - i) + c * (i * 2)
    if ans > temp:
      ans = temp
  print(ans)

Submission status: Wrong Answer

Solution code:
import itertools
a,b,c,x,y = map(int, input().split(" "))
ans = 10 ** 11

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

else:
  for i in range(min(x, y) + 1):
    temp = a * (x - i) + b * (y - i) + c * (i * 2)
    if ans > temp:
      ans = temp
  print(ans)

Submission status: Wrong Answer

Solution code:
import itertools
a,b,c,x,y = map(int, input().split(" "))
ans = 10 ** 10

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

else:
  for i in range(min(x, y) + 1):
    temp = a * (x - i) + b * (y - i) + c * (i * 2)
    if ans > temp:
      ans = temp
  print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

total = a*x+b*y
if a/2 + b/2 > c:
    if a > c and b > c:
        total = max(x,y)*2*c
    elif a < c and x >y:
        total = y*2*c+ round(x-y)*a
    elif b < c and y >x:
        total = x*2*c+ round(y-x)*b


print(total)

Submission status: Wrong Answer

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

plan1 = (A*X) + (B*Y)
plan2 = (C*2) * max(X,Y)
plan3 = (C*2) * X + B*(Y-X)
plan4 = (C*2) * Y + A*(Y-X)

if X <= Y:
  print(min(plan1,plan2,plan3))
else:
  print(min(plan1,plan2,plan4))

Submission status: Wrong Answer

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

ans = float('inf')

if A + B >= 2 * C:
    p = (2 * max(X, Y)) * C
    ans = min(ans, p)
else:
    for x in range(X + 1):
        for y in range(Y + 1):
            c = max(X - x, Y - y)
            p = x * A + y * B + (2 * c) * C
            ans = min(ans, p)

print(ans)

Submission status: Wrong Answer

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

m = 10^10
for i in range(X+1):
  for j in range(Y+1):
    k = min(2*X-i,2*Y-j)
    m = min(m,A*i+B*j+C*k)
    
print(m)

Submission status: Wrong Answer

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

m = 10^10
for i in range(X):
  for j in range(Y):
    k = max(2*X-2*i,2*Y-2*j)
    m = min(m,A*i+B*j+C*k)
    
print(m)

Submission status: Wrong Answer

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

m = 10^10
for i in range(X):
  for j in range(Y):
    k = max(2*X-i,2*Y-j)
    m = min(m,A*i+B*j+C*k)
    
print(m)

Submission status: Wrong Answer

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

m = 10^10
for i in range(X):
  for j in range(Y):
    k = min(2*X-i,2*Y-j)
    m = min(m,A*i+B*j+C*k)
    
print(m)

Submission status: Wrong Answer

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

ans = float('inf')

if A + B > 2 * C:
    p = (2 * max(X, Y)) * C
    ans = min(ans, p)
else:
    for x in range(X + 1):
        for y in range(Y + 1):
            c = max(X - x, Y - y)
            p = x * A + y * B + (2 * c) * C
            ans = min(ans, p)

print(ans)

Submission status: Wrong Answer

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

m = 10^9
for i in range(X):
  for j in range(Y):
    m = min(m,A*i+B*j+C*((X+Y)-(i+j)))
    
print(m)

Submission status: Wrong Answer

Solution code:
def half_and_half(a,b,c,x,y):
    z = x   if a > b else y
    can = []
    
    for n in range(z+1):
        p = x - n if x > n else 0
        q = y - n if y > n else 0
        amount = p*a + q*b + n*c*2
        #print("%d = %d x %d + %d x %d + %d x %d " %(amount,p,a,q,b,n,c))
        can.append(amount)

    print(min(can))

if __name__ == '__main__':
    a,b,c,x,y = map(int,input().split())
    half_and_half(a,b,c,x,y)

Submission status: Wrong Answer

Solution code:
def half_and_half(a,b,c,x,y):
    z = x   if a > b else y
    can = []
    
    for n in range(z+1):
        p = x - n if x >= n else 0
        q = y - n if y >= n else 0
        amount = p*a + q*b + n*c*2
        #print("%d = %d x %d + %d x %d + %d x %d " %(amount,p,a,q,b,n,c))
        can.append(amount)

    #i * 2c + max(0,x-i)*a + max(0,y-i)*b
    print(min(can))
if __name__ == '__main__':
    a,b,c,x,y = map(int,input().split())
    half_and_half(a,b,c,x,y)

Submission status: Wrong Answer

Solution code:

import math
def half_and_half(a,b,c,x,y):
    #z = x * 2  if a > b else y *2
    z = x   if a > b else y
    can = []
    
    for n in range(z,-1,-1):
        #p = x - n//2 if x > n//2 else 0
        #q = y - n//2 if y > n//2 else 0
        #amount = p*a + q*b + n*c
        p = x - n if x >= n else 0
        q = y - n if y >= n else 0
        amount = p*a + q*b + n*c*2
        #print("%d = %d x %d + %d x %d + %d x %d " %(amount,p,a,q,b,n,c))
        can.append(amount)

    #i * 2c + max(0,x-i)*a + max(0,y-i)*b
    print(min(can))
if __name__ == '__main__':
    a,b,c,x,y = map(int,input().split())
    half_and_half(a,b,c,x,y)

Submission status: Wrong Answer

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

min_price = A * X + B * Y

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

if X > 0 and A > 2 * C:
    min_price -= (A - 2 * C) * X

if Y > 0 and B > 2 * C:
    min_price -= (B - 2 * C) * Y

print(min_price)

Submission status: Wrong Answer

Solution code:
def main():
  A, B, C, X, Y = map(int, input().split())
  if A + B <= 2*C:
    print(A*X + B*Y)
  elif 2*C < A and 2*C < B:
    print(C*max(X,  Y)*2)
  elif 2*C < A or 2*C < B:
    print(C*max(X,  Y)*2)
  else:
    if X < Y:temp = B
    else:  temp = A
    print(C*min(X, Y)*2 + temp*(abs(X-Y)))
if __name__ == "__main__":
  main()

Submission status: Wrong Answer

Solution code:
def main():
  A, B, C, X, Y = map(int, input().split())
  if A + B <= 2*C:
    print(A*X + B*Y)
  elif 2*C < A or 2*C < B:
    print(C*max(X,  Y)*2)
  else:
    if X < Y:temp = B
    else:  temp = A
    print(C*min(X, Y)*2 + temp*(abs(X-Y)))
if __name__ == "__main__":
  main()

Submission status: Wrong Answer

Solution code:
def main():
  A, B, C, X, Y = map(int, input().split())
  if A + B <= 2*C:
    print(A*X + B*Y)
  elif 2*C < A and 2*C < B:
    print(C*max(X,  Y)*2)
  else:
    if X < Y:temp = B
    else:  temp = A
    print(C*min(X, Y)*2 + temp*(abs(X-Y)))
if __name__ == "__main__":
  main()

Submission status: Wrong Answer

Solution code:
def main():
  A, B, C, X, Y = map(int, input().split())
  if A + B <= 2*C:
    print(A*X + B*Y)
  elif 2*C <= A and 2*C <= B:
    print(C*max(X,  Y)*2)
  else:
    if X < Y:temp = B
    else:  temp = A
    print(C*min(X, Y)*2 + temp*(abs(X-Y)))
if __name__ == "__main__":
  main()

Submission status: Wrong Answer

Solution code:
def main():
  A, B, C, X, Y = map(int, input().split())
  if A + B < 2*C:
    print(A*X + B*Y)
  elif 2*C <= A and 2*C <= B:
    print(C*max(X,  Y)*2)
  else:
    if X < Y:temp = B
    else:  temp = A
    print(C*min(X, Y)*2 + temp*(abs(X-Y)))
if __name__ == "__main__":
  main()

Submission status: Wrong Answer

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

List=[(A*3)+(B*2)]

AB=0
AP=0
BP=0
ANS=0
while 1:
    if AP>=X and BP>=Y:
        #print(ANS)
        List.append(ANS)
        break
    if AB==2:
        AP+=1
        BP+=1
        AB=0
    else:
        ANS+=C
        AB+=1

AB=0
AP=X
BP=Y
ANS=0
while 1:
    if AP==0:
        ANS+=(BP*B)
        List.append(ANS)
        break
    elif BP==0:
        ANS+=(AP*A)
        List.append(ANS)
        break
    else:
        if AB==2:
            AP-=1
            BP-=1
            AB=0
        else:
            ANS+=C
            AB+=1
        
print(min(List))

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
import copy
from queue import Queue
import heapq
import numpy as np

MOD = 5000000007

#n = int(input())
#b = int(input())
a, b, c, x, y = [int(i) for i in input().split()]
#table = [[int(i)  for i in input().split()] for j in range(m)]
#table = [list(input()) for n in range(r)] #table[h][w]
#p = [int(i) for i in input().split()]
#s = [int(i) for i in range(n)]
#p = [int(input()) for i in range(m)]
#s = input()

#list = list(s)
#dp = [MOD for _ in range(m)]
#dp = [[0 for _ in range(n+1)] for _ in range(n+1)]
#dp = [[[0 for _ in range(11)] for _ in range(2)] for _ in range(11)]

#Combination = [[0 for _ in range(n+1)] for _ in range(n+1)]
#b = [[0 for _ in range(n+1)] for _ in range(n+1)]

kotae = 500000001
if (x > y):
    max = x
else:
    max = y
for i in range(0,max+1):
    j = x - i
    k = y - i
    if(j < 0):
        j = 0
    if(k < 0):
        k = 0
    temp = a * j + b * k + 2 * c * i
    if (temp < kotae):
        kotae = temp

print(kotae)

Submission status: Wrong Answer

Solution code:
import math
import copy
from queue import Queue
import heapq
import numpy as np

MOD = 5000000007

#n = int(input())
#b = int(input())
a, b, c, x, y = [int(i) for i in input().split()]
#table = [[int(i)  for i in input().split()] for j in range(m)]
#table = [list(input()) for n in range(r)] #table[h][w]
#p = [int(i) for i in input().split()]
#s = [int(i) for i in range(n)]
#p = [int(input()) for i in range(m)]
#s = input()

#list = list(s)
#dp = [MOD for _ in range(m)]
#dp = [[0 for _ in range(n+1)] for _ in range(n+1)]
#dp = [[[0 for _ in range(11)] for _ in range(2)] for _ in range(11)]

#Combination = [[0 for _ in range(n+1)] for _ in range(n+1)]
#b = [[0 for _ in range(n+1)] for _ in range(n+1)]

kotae = 500000001
if (x > y):
    max = x
else:
    max = y
for i in range(0,2 * max+1,2):
    j = x - (i // 2)
    k = y - (i // 2)
    if(j < 0):
        j = 0
    if(k < 0):
        k = 0
    temp = a * j + b * k + c * i
    if (temp < kotae):
        kotae = temp

print(kotae)

Submission status: Wrong Answer

Solution code:
a,b,c,x,y=map(int,input().split())
mc=min(a,b,c)
mp=max(x,y)
cost=1000000000000
if mc==c:
  for i in range(mp):
    cost_=(mp-i)*2*c+min(a,b)*i
    if cost_ > cost:
      #print(cost)
      break;
    else:
      cost=cost_
  print(cost)
if mc==a:
  for i in range(x):
    cost_=(x-i)*a+b*(y-i)+c*2*i
    if cost_ > cost:
      #print(cost)
      break;
    else:
      cost=cost_
  print(cost)  
if mc==b:
  for i in range(y):
    cost_=(x-i)*a+b*(y-i)+c*2*i
    if cost_ > cost:
      #print(cost)
      break;
    else:
      cost=cost_
  print(cost)

Submission status: Wrong Answer

Solution code:
a,b,c,x,y=map(int, input().split())
mc=min(a,b,c)
mp=max(x,y)
cost=10000000000
if mc==c:
  for i in range(mp):
    cost_=(mp-i)*2*c+min(a,b)*i
    if cost_ > cost:
      #print(cost)
      break;
    else:
      cost=cost_
  print(cost)
if mc==a:
  for i in range(x):
    cost_=(x-i)*a+b*(y-i)+c*2*i
    if cost_ > cost:
      #print(cost)
      break;
    else:
      cost=cost_
  print(cost)  
if mc==b:
  for i in range(y):
    cost_=(x-i)*a+b*(y-i)+c*2*i
    if cost_ > cost:
      #print(cost)
      break;
    else:
      cost=cost_
  print(cost)

Submission status: Wrong Answer

Solution code:
a,b,c,x,y=map(int, input().split())
mc=min(a,b,c)
mp=max(x,y)
cost=10000000000
if mc==c:
  for i in range(mp):
    cost_=(mp-i)*2*c+min(a,b)*i
    if cost_ >= cost:
      print(cost)
    else:
      cost=cost_
  print(cost)
if mc==a:
  for i in range(x):
    cost_=(x-i)*a+b*(y-i)+c*2*i
    if cost_ >= cost:
      print(cost)
    else:
      cost=cost_
  print(cost)  
if mc==b:
  for i in range(y):
    cost_=(x-i)*a+b*(y-i)+c*2*i
    if cost_ >= cost:
      print(cost)
    else:
      cost=cost_
  print(cost)

Submission status: Wrong Answer

Solution code:
a,b,c,x,y=map(int, input().split())
mc=min(a,b,c)
mp=max(x,y)
cost=10000000000
if mc==c:
  for i in range(mp):
    cost_=(mp-i)*2*c+min(a,b)*i
    if cost_ >= cost:
      print(cost)
    else:
      cost=cost_
if mc==a:
  for i in range(x):
    cost_=(x-i)*a+b*(y-i)+c*2*i
    if cost_ >= cost:
      print(cost)
    else:
      cost=cost_
if mc==b:
  for i in range(y):
    cost_=(x-i)*a+b*(y-i)+c*2*i
    if cost_ >= cost:
      print(cost)
    else:
      cost=cost_

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

ans = 10**5
for i in range(10**5):
    tmp = 2*c*i + (x-i)*a + (y-i)*b
    ans = min(ans, tmp)
    if i >= x or i >= y:
        break
print(ans)

Submission status: Wrong Answer

Solution code:
a, b, ab, x, y = map(int, input().split())
if a+b <= 2*ab:
    print(a*x+b*y)
    exit()
if a >= 2*ab and b >= 2*ab:
    print(max(x,y)*2*ab)
    exit()
mix = min(x,y)*2*ab
f = lambda x, y: a if x - y >= 0 else b
print(mix+f(x, y)*abs(x-y))

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
A, B, C, X, Y = map(int, input().split())
res = float('Inf')
for Z in range(10**5):
    total = 2*Z*C + max(0, X - Z)*A + max(0, Y - Z)*B
    if res > total:
        res = total
print(res)

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
from math import ceil, floor, sqrt, sin, cos, pi
from itertools import accumulate, permutations, combinations
from fractions import gcd # 最大公約数
from collections import deque, Counter
from operator import itemgetter
from heapq import heappop,heappush
sys.setrecursionlimit(10**7)
def lcm(x, y): return ((x * y) // gcd(x, y)) # 最小公倍数
# list(map(int, input().split()))
# map(int, input().split())
# int(input())
# input().split()
# mojiretu = ','.join(str_list)
# sorted(input())
a, b, c, x , y = map(int, input().split())
ans = []
# そのまま
ans.append(a*x + b*y)
# 全部1/2
ans.append(max(x, y)*c*2)
# 1/2 あまりをそのまま
ans.append(min(x, y)*c*2 + (abs(x - y) * a))
print(min(ans))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

AB = A + B

num_A = 0
num_B = 0
num_C = 0
ans_cost = 5000 * 2 * 10**5
if 2 * C > AB:
    num_A = X
    num_B = Y
    num_C = 0
    ans_cost = int(A*num_A + B*num_B + C*num_C)
else:
    min_C = min(X,Y) *2
    max_C = max(X,Y) *2
    for i in range(min_C, max_C+1, 2):
        num_A = X - i / 2
        num_B = Y - i / 2
        if num_A < 1:
            num_A = 0
        if num_B < 1:
            num_B = 0
        
        total_cost = int(A*num_A + B*num_B + C*i)
    
        if total_cost < ans_cost:
            ans_cost = total_cost

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

Submission status: Wrong Answer

Solution code:
a,b,c,x,y=[int(i)  for i in input().split()]
ans=1000000000
for k in range(10**5):
	money=2*c*k + max(x-k,0)*a + max(y-k,0)*b
	if(ans>money):
		ans=money
print(ans)

Submission status: Wrong Answer

Solution code:
a,b,c,x,y=[int(i)  for i in input().split()]
ans=1000000
for k in range(10**5):
	money=2*c*k + max(x-k,0)*a + max(y-k,0)*b
	if(ans>money):
		ans=money
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

costs = 0

while x>0 and y>0:
  if a+b>2*c:
    costs += 2*c
  else:
    costs = costs+a+b
  x -= 1
  y -= 1
  
if x>0:
  if a<=2*c:
    costs += x*a
  else:
    costs += x*2*c
    
if y>0:
  if b<=2*c:
    costs += x*b
  else:
    costs += x*2*c
  
print(costs)

Submission status: Wrong Answer

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

costs = 0

while x>0 and y>0:
  if a+b>2*c:
    costs += 2*c
  else:
    costs = costs+a+b
  x -= 1
  y -= 1
  
if x>0:
  if a<=2*c:
    costs += x*a
  else:
    costs += x*2*c