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())
ans=a*x+b*y
for ab in range(1,max(a,b)):
    if 2*ab*c+a*(max(x-ab,0))+b*(max(0,y-ab))<ans:
        ans=2*ab*c+a*(max(x-ab,0))+b*(max(0,y-ab))
print(ans)

Submission status: Wrong Answer

Solution code:
# AtCoder Beginner Contest 095 C - Half and Half
import sys

A, B, C, X, Y = map(int, sys.stdin.readline().strip().split())

ans = A * X + B * Y
for z in range(2, 10 ** 5 + 1, 2):
    x = max(X - int(z / 2), 0)
    y = max(Y - int(z / 2), 0)

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

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

Submission status: Wrong Answer

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

abs_AB = abs(A - B)
abs_AC = abs(A - C)
abs_BC = abs(B - C)

sum_money = 0.0
if A < B and abs_BC - abs_AC > 0:
    a_x = 0
    for y in range(2 * Y):
        sum_money = sum_money + C
        a_x += 0.5
    a_x = int(a_x)
    for x in range(X - a_x):
        sum_money = sum_money + A

elif A > B and abs_AC - abs_BC > 0:
    b_y = 0
    for x in range(2 * X):
        sum_money = sum_money + C
        b_y += 0.5
    b_y = int(b_y)
    for y in range(Y - b_y):
        sum_money = sum_money + B

else:
    for y in range(Y):
        sum_money = sum_money + B
    for x in range(X):
        sum_money = sum_money + A

print(int(sum_money))

Submission status: Wrong Answer

Solution code:
a,b,c,x,y=map(int,input().split())
cost=[]
cm=0
while cm<=max(x,y):
    am=x-cm//2    
    bm=y-cm//2
    if am>=0 and bm>=0: cost.append(am*a+bm*b+cm*c)
    elif am>=0 and bm<=0: cost.append(am*a+cm*c)
    elif am<=0 and bm>=0: cost.append(bm*b+cm*c)
    elif am<=0 and bm<=0: cost.append(cm*c)
    cm+=2
print(min(cost))

Submission status: Wrong Answer

Solution code:
a,b,c,x,y=map(int,input().split())
cost=[]
cm=0
while cm<=max(x,y):
    am=x-cm//2    
    bm=y-cm//2
    if am>=0 and bm>=0:
        cost.append(am*a+bm*b+cm*c)
    cm+=2
print(min(cost))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a, b, c, x, y = map(int, input().split())
A = (a, x)
B = (b, y)
ans = 0
if A[0]+B[0] > 2*c:
    mn = min(A, B, key=lambda x: x[1])
    mx = max(A, B, key=lambda x: x[1])
    q, r = divmod(mn[1], 2)
    e1 = 2*q * 2*c + mn[0] * r + (mx[1]-2*q) * mx[0]
    e2 = mx[1] * 2*c
    ans = min(e1, e2)
else:
    ans += A[0]*A[1] + B[0]*B[1]

print(ans)

Submission status: Wrong Answer

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

#ハーフ2枚より別々の方が安い
if a+b <= 2*c:
  print(a*x + b*y)
  exit()
#ハーフの方が安くてAの枚数が多い
elif x >= y:
  #Aの方がハーフ2枚より高いとき
  if a >= 2*c:
    print(c*x)
    exit()
  elif a < 2*c:
    print(a*(x-y) + 2*c*y)
    exit()
else:
  if b >= 2*c:
    print(2*c*y)
    exit()
  elif b < 2*c:
    print(b*(y-x) + 2*c*y)
    exit()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a,b,c,x,y = map(int,input().split())
A_B = a*x+b*y
A_AB = a*x+2*c*y
AB_B = 2*c*x+b*y
AB = 2*c*max(x,y)
ans = min(A_B,A_AB,AB_B,AB)
print(ans)

Submission status: Wrong Answer

Solution code:
a,b,c,x,y = map(int,input().split())
A_B = a*x+b*y
A_AB = a*x+c*y
AB_B = c*x+b*y
AB = c*max(x,y)
ans = min(A_B,A_AB,AB_B,AB)
print(ans)

Submission status: Wrong Answer

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

l = a * x + b * y
m = c * max(x, y) * 2

if x >= y :
    n = c * y * 2 +  a * (x - y)
else:
    n = c * x * 2 + a * (y - x)

ans = min(l, min(m, n))
print(ans)

Submission status: Wrong Answer

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

l = a * x + b * y
m = c * max(x, y) * 2

if x >= y :
    n = c * y * 2 +  a * (x - y)
else:
    n = c * x * 2 + a * (y - x)

ans = min(l, m, n)
print(ans)

Submission status: Wrong Answer

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

K = 2 * C - A - B
S = A*X + B*Y
z = min(X, Y)
Z = max(X, Y)

if K >= 0:
  print(S)
elif K < 0 and S >= Z*C*2:
  print(Z*C*2)
else:
  t =-1 * S/K
  zz =min(z, int(t))
  P =S + K* zz
  print(P)

Submission status: Wrong Answer

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

K = 2 * C - A - B
S = A*X + B*Y
t =-1 * S * K
z = min(X, Y, t)
Z = max(X, Y)

if K >= 0:
  print(S)
elif S > Z*C*2:
  print(Z*C*2)
else:
  P =S + K* z
  print(P)

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/abc095/tasks/arc096

# 値段,枚数
A, B, C, X, Y = map(int, input().split())

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

print(ans)

Submission status: Wrong Answer

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

v1 = max(x*2,y*2)*c
v2 = a*x+b*y
v3 = min(x,y)*c*2 + abs(x-y)*min(a,b)

# print(v1,v2,v3)
print(min(v1,v2,v3))

Submission status: Wrong Answer

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

#a,bピザをx,y用意する
#シンプルに用意する場合a*x+b*y
#abピザがa+bより安い場合代替する

#a,b<ab a+b>abより高い場合
if a+b>=c*2:
    ans = c*2*(max(x,y))
if a+b<c*2:
    ans = a*x+b*y
#a<ab<b
#abピザでbを用意して、残りのaはaで用意する
if a<=c<=b:
    ans = min(c*2*y+max(x-y,0)*a,ans)
if b<=c<=a:
    ans = min(c*2*x+max(y-x,0)*b,ans)

print(ans)

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/abc095/tasks/arc096

# 値段,枚数
A, B, C, X, Y = map(int, input().split())

# C * 2 は　A + Bとなる
ans = max(X, Y) * 2 * C

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

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

print(ans)

Submission status: Wrong Answer

Solution code:
# https://atcoder.jp/contests/abc095/tasks/arc096

# 値段,枚数
A, B, C, X, Y = map(int, input().split())

# C * 2 は　A + Bとなる
ans = max(X, Y) * 2 * C

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

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

print(ans)

Submission status: Wrong Answer

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

# C * 2 は　A + Bとなる
ans = max(X, Y) * 2 * C

ans = min(ans, A * X + B * Y)

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

print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

print(Sum)

Submission status: Wrong Answer

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

for x in range(X+1):
  for y in range(Y+1):
    if x <= y:
      z = 2 * (X - x)
    else:
      z = 2 * (Y - y)
    Sum = A * x + B * y + C * z
    if Sum < min:
      min = Sum

print(Sum)

Submission status: Wrong Answer

Solution code:
a, b, c, x, y = map(int, input().split())
ans1 = a * x + b * y  #そのまま
if x > y:  #少ない方をABで補う
    ans2 = c * min(x, y) * 2 + a * (x - y)
else:
    ans2 = c * min(x, y) * 2 + b * (y - x)
ans3 = c * max(a, b) * 2  #すべてABで
print(min(ans1, ans2, ans3))

Submission status: Wrong Answer

Solution code:
A, B, C, X, Y = map(int, input().split())
value = float('inf')
D = max(A,B)
for i in range(D+1):
  E = max((X-i)*A, 0)
  F = max((Y-i)*B, 0)
  valueX = 2*i*C+E+F
  if valueX < value:
    value  = valueX
print(str(value))

Submission status: Wrong Answer

Solution code:
A, B, C, X, Y = map(int, input().split())
value = float('inf')
D = max(A,B)
for i in range(D+1):
  E = min((X-i)*A, 0)
  F = min((Y-i)*B, 0)
  valueX = 2*i*C+E+F
  if valueX < value:
    value  = valueX
print(str(value))

Submission status: Wrong Answer

Solution code:
A, B, C, X, Y = map(int, input().split())
value = float('inf')
D = max(A,B)
for i in range(D+1):
  valueX = 2*i*C+(X-i)*A+(Y-i)*B
  if valueX < value:
    value  = valueX
print(str(value))

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

Submission status: Wrong Answer

Solution code:
import numpy as np
def f(s):
    a, b, c, x, y = map(int, s.split())
    Min = np.inf
    for use_c in range(max(x, y) * 2 + 1):
        price = use_c * c + max(0, x - use_c // 2) * a + max(0, y - use_c // 2) * b
        if price < Min:
            Min = price
    print(Min)

Submission status: Wrong Answer

Solution code:
# ABC095C

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

Submission status: Wrong Answer

Solution code:
# ABC095C

a, b, c, x, y = map(int, input().split())
if a > c or b > c:
    t = min(x, y)
    print("(1)", (x - t)*a + (y - t)*b + t*2*c)
else:
    print("(2)", a*x + b*y)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

for i in range(0, max(2*x + 1, 2*y + 1), 2):
    if x >= y and i <= 2 * y:
        if price > a * (x - i/2) + b * (y - i/2) + c * i :
            price = int(a * (x - i/2) + b * (y - i/2) + c * i)
    if x >= y and 2*y <= i <= 2*x:
        if price > a * (x - i/2) + c * i :
            price = int(a * (x - i/2) + c * i)
    if x < y and i <= 2*x:
        if price > a * (x - i/2) + b * (y - i/2) + c * i :
            price = int(a * (x - i/2) + b * (y - i/2) + c * i)
    if x < y and 2*x <= i <= 2*y:
        if price > a * (y - i/2) + c * i :
            price = int(a * (y - i/2) + c * i)

print(price)

Submission status: Wrong Answer

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

for i in range(0, max(2 * x + 1, 2 * y + 1), 2):
    if x >= y and i <= 2 * y:
        if price > a * (x - i / 2) + b * (y - i / 2) + c * i :
            price = int(a * (x - i / 2) + b * (y - i / 2) + c * i)
    if x >= y and 2*y <= i:
        if price > a * (x - i / 2) + c * i :
            price = int(a * (x - i / 2) + c * i)
    if x < y and i <= 2 * x:
        if price > a * (x - i / 2) + b * (y - i / 2) + c * i :
            price = int(a * (x - i / 2) + b * (y - i / 2) + c * i)
    if x < y and 2*x <= i:
        if price > a * (y - i / 2) + c * i :
            price = int(a * (y - i / 2) + c * i)

print(price)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
a, b, c, x, y = map(int, input().split())

total = a * x + b * y
c_total = 2 * c * min(x, y)
if total > c_total:
  total = c_total
  if x > y:
    total += c_total + (x - y) * min(a, 2 * c)
  elif y > x:
    total += c_total + (y - x) * min(b, 2 * c)
print(total)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
a, b, c, x, y = map(int, input().split())

total = a * x + b * y

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

Submission status: Wrong Answer

Solution code:
A, B, C, X, Y = map(int, input().split())
ans = 1 << 30
# ABピザを全探索して考える
for i in range(max(2*X,2*Y)+1, 2):
    x = X - i // 2
    y = Y - i // 2
    ans = min(ans, A * max(0,x) + B * max(0,y) + C * i)

print(ans)

Submission status: Wrong Answer

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

ans = 0

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

print(ans)

Submission status: Wrong Answer

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

ans = 0

if 4 * C < (A + B):
  ans = C * max(X,Y) * 2
elif 2 * C < A + B:
  if X > Y:
    ans = Y * 2 * C + (X - Y) * A
  else:
    ans = X * 2 * C + (Y - X) * B
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 4 * C <= (A + B):
  ans = C * max(X,Y) * 2
elif 2 * C <= A + B:
  if X > Y:
    ans = Y * 2 * C + (X - Y) * A
  else:
    ans = X * 2 * C + (Y - X) * B
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 4 * C < (A + B):
  ans = C * max(X,Y) * 2
elif C < int((A + B) / 2):
  if X > Y:
    ans = Y * 2 * C + (X - Y) * A
  else:
    ans = X * 2 * C + (Y - X) * B
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 a > c * 2 and b > c * 2:
    ans = max(x, y) * 2 * c
elif a + b > c * 2:
    mini= min(x, y)
    x -= mini
    y -= mini
    ans = mini * 2 * c + x * a + 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())
ans = 0

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

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def resolve():
    a, b, c, x, y = map(int, input().split())
    p1 = x*a + y*b
    minp = min(x, y)
    if x >= y:
        p2 = minp*2*c + (max(x, y)-minp)*a

    else:
        p2 = minp * 2 * c + ((max(x, y) - minp) * 2) * b
    p3 = max(x, y) * 2 * c
    print(min(p1, p2, p3))

resolve()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a, b, c, x, y = [int(i) for i in input().split()]
ans = 10**18
for i in range(min(x, y)*2 + 1):
    ans = min(ans, c * i + (x - i//2) * a + (y - i//2) * b)
print(ans)

Submission status: Wrong Answer

Solution code:
a, b, c, x, y = [int(i) for i in input().split()]
ans = 10**18
for i in range(min(x, y)*2 + 1):
    ans = min(ans, c * i*2 + (x - i//2) * a + (y - i//2) * b)
print(ans)

Submission status: Wrong Answer

Solution code:
a, b, c, x, y = [int(i) for i in input().split()]
ans = 10**18
for i in range(min(x, y) + 1):
    ans = min(ans, c * i*2 + (x - i) * a + (y - i) * b)
print(ans)

Submission status: Wrong Answer

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

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

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    a,b,c,x,y=map(int,input().split())
    ans=10**10
    yen=0
    if a+b>c*2:
        yen+=(c*2*min(x,y))
        x,y=x-min(x,y),y-min(x,y)

        if x>0:
            if a<c:
                yen+=x*a
            else:
                yen+=x*2*c
        else:
            if b<c:
                yen+=y*b
            else:
                yen+=y*2*c

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

resolve()

Submission status: Wrong Answer

Solution code:
A, B, C, X, Y = map(int, input().split())
# A, B を1枚ずつ
if 2*C > A+B:
    print(A*X+B*Y)
else:
    if X < Y:
        Y -= X
        print(2*C+B*Y)
    else:
        X -= Y
        print(2*C+A*X)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if boundary_value <= (min_value + max_value):
    if boundary_value <= min_value:
        print(boundary_value * max(x, y))
    elif (a == max_value and y <= x) or (b == max_value and x <= y):
        print(boundary_value * max(x, y))
    else:
        print(boundary_value * (max(x, y) - abs(x - y)) +
              min_value * abs(x - y))
elif (min_value + max_value) < boundary_value:
    print(a * x + b * y)

Submission status: Wrong Answer

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

if boundary_value <= min_value:
    print(boundary_value * max(x, y))
elif min_value < boundary_value <= (min_value + max_value):
    if (a == max_value and y <= x) or (b == max_value and x <= y):
        print(boundary_value * max(x, y))
    else:
        print(boundary_value * (max(x, y) - abs(x - y)) +
              min_value * abs(x - y))
elif (min_value + max_value) < boundary_value:
    print(a * x + b * y)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

cost = 0
for i in range(min(x, y)):
    if a + b > 2 * c:
        cost += 2 * c
    else:
        cost += a + b

for i in range(abs(x - y)):
    if a < 2 * c:
        cost += a
    elif b < 2 * c:
        cost += b
    else:
        cost += 2 * c

print(cost)

Submission status: Wrong Answer

Solution code:
A, B, C, X, Y = map(int, input().split())
cost1 =  A+B; cost2 = C*2

if X == Y :
  print( X* min( cost1, cost2))
if X> Y:
  print( min( Y* min( cost1, cost2) + (X-Y)*A , X* min( cost1, cost2)))
else :
  print( min( X* min( cost1, cost2) + (Y-X)*B , Y* min( cost1, cost2)))

Submission status: Wrong Answer

Solution code:
A, B, C, X, Y = map(int, input().split())
cost1 =  A+B; cost2 = C*2

if X == Y :
  print( X* min( cost1, cost2))
if X> Y:
  print( min( Y* min( cost1, cost2) + (X-Y)*A , X* min( cost1, cost2)))
else :
  print( min( X* min( cost1, cost2) + (Y-X)*A , Y* min( cost1, cost2)))

Submission status: Wrong Answer

Solution code:
pa, pb, pab, x, y = map(int, input().split())
li = []
if x-y>= 0:
    li.append(pa*x+pb*y)
    li.append(pa*(x-y)+pab*2*y)
    li.append(pab*2*x)
if y-x>= 0:
    li.append(pa*x+pb*y)
    li.append(pb*(y-x)+pab*2*y)
    li.append(pab*2*y)
li.sort()
print(li[0])

Submission status: Wrong Answer

Solution code:
pa, pb, pab, x, y = map(int, input().split())
li = []
if x-y>= 0:
    li.append(pa*x+pb*y)
    li.append(pa*(x-y)+pab*2*y)
    li.append(pa*(x-y+1)+pb+pab*2*(y-1))
    li.append(pab*2*x)
    li.append(pa+pab*2*(x-1))
if y-x>= 0:
    li.append(pa*x+pb*y)
    li.append(pb*(y-x)+pab*2*y)
    li.append(pa+pb*(y-x+1)+pab*2*(y-1))
    li.append(pab*2*y)
    li.append(pb+pab*2*(y-1))
li.sort()
print(li[0])

Submission status: Wrong Answer

Solution code:
pa, pb, pab, x, y = map(int, input().split())
li = []
if x-y>= 0:
    li.append(pa*x+pb*y)
    li.append(pa*(x-y)+pab*2*y)
    li.append(pa*(x-y+1)+pb+pab*2*(y-1))
    li.append(pab*2*x)
if y-x>= 0:
    li.append(pa*x+pb*y)
    li.append(pb*(y-x)+pab*2*y)
    li.append(pa+pb*(y-x+1)+pab*2*(y-1))
    li.append(pab*2*y)
li.sort()
print(li[0])

Submission status: Wrong Answer

Solution code:
pa, pb, pab, x, y = map(int, input().split())
li = []
if x-y>= 0:
    li.append(pa*x+pb*y)
    li.append(pa*(x-y)+pab*2*y)
    li.append(pa*(x-y+1)+pb+pab*2*(y-1))
    li.append(pab*2*x)
else:
    li.append(pa*x+pb*y)
    li.append(pb*(y-x)+pab*2*y)
    li.append(pa+pb*(y-x+1)+pab*2*(y-1))
    li.append(pab*2*y)
li.sort()
print(li[0])

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

Solution code:
# 2020/04/23
# AtCoder Beginner Contest 095 - C

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

# Calc
case1 = a * x + b * y
case2 = x * 2 * c + max(0, (x * 2 - y) * b)
case3 = max(0, (y * 2 - x) * a) +  y * 2 * c
case4 = max(x, y) * 2 * c

ans = min(case1, case2, case3, case4)

# Output
print(ans)

Submission status: Wrong Answer

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

A_B = A * X + B * Y
all_C = max(X, Y) * 2 * C
part_C = min(X, Y) * 2 * C + (A < B) * (B - A) * X + (B < A) * (A - B) * Y

print(min(A_B, all_C, part_C))

Submission status: Wrong Answer

Solution code:
A,B,C,X,Y = map(int,input().split())
if A<=C  and B<=C:
  print(A*X+B*Y)
  
elif C<=A and C<=B:
  if X<=Y:
    a = 2*C*X+(Y-X)*B
    b = 2*C*Y 
    print(min(a,b))
  else:
    a = 2*C*Y+(X-Y)*A
    b = 2*C*X
    print(min(a,b))
    
elif A<=C and B>=C:
    a = 2*C*Y+(X-Y)*A
    b = A*X +B*Y
    print(min(a,b))
else:
    a = 2*C*X+(Y-X)*B
    b = A*X +B*Y
    print(min(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(A*X+B*Y)
  
elif C<=A and C<=B:
  if X<=Y:
    a = 2*C*X+(Y-X)*B
    b = 2*C*Y 
    print(min(a,b))
  else:
    a = 2*C*Y+(X-Y)*A
    b = 2*C*X
    print(min(a,b))
    
elif A<=C and B>C:
    a = 2*C*Y+(X-Y)*A
    b = A*X +B*Y
    print(min(a,b))
else:
    a = 2*C*X+(Y-X)*B
    b = A*X +B*Y
    print(min(a,b))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# coding: utf-8

# https://atcoder.jp/contests/abc095/tasks/arc096_a
# 16:32-16:44


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

    if y > x:
        a = b
        b = a
        x = y
        y = x
    # aの方が枚数（x)多い

    ans = 0
    if a+b > 2*c:
        ans += 2*c*y
        x -= y
        y = 0

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

    return ans


print(main())

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

a_total = A * X
b_total = B * Y

total = a_total + b_total

c_mul = (X + Y) // 2

c_total = C * (2 * c_mul)

if X > Y:
    c_total += A * (X - c_mul)
if Y > X:
    c_total += B * (Y - c_mul)

if total > c_total:
    print(c_total)
else:
    print(total)

Submission status: Wrong Answer

Solution code:
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

def main():
    a, b, c, x, y = nm()

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

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

a = A*X+B*Y

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


print(min(a, b))

Submission status: Wrong Answer

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

a = A*X+B*Y

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


print(min(a, b))

Submission status: Wrong Answer

Solution code:
sum = 0
A,B,C,X,Y = map(int,input().split())
AB = C*2
ans = float("inf")

for i in range(10**5+1):
    sum = AB*i + A*min(0,X-i) + B*min(0,Y-i)
    if sum < ans:
        ans = sum

print(ans)

Submission status: Wrong Answer

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

ans2 = x*a + y*b

ab = max(x, y)//2 * 2
ans3 = ab*2*c + max(0, x-ab)*a + max(0, y-ab)*b

ab = -(-max(x, y)//2) * 2
ans4 = ab*2*c + max(0, x-ab)*a + max(0, y-ab)*b

ab = -(-min(x, y)//2) * 2
ans5 = ab*2*c + max(0, x-ab)*a + max(0, y-ab)*b
print(min(ans1, ans2, ans3, ans4, ans5))

Submission status: Wrong Answer

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

ans2 = x*a + y*b

ab = max(x, y)//2 * 2
ans3 = ab*2*c + max(0, x-ab)*a + max(0, y-ab)*b

ab = -(-max(x, y)/2) * 2
ans4 = ab*2*c + max(0, x-ab)*a + max(0, y-ab)*b

ab = -(-min(x, y)/2) * 2
ans5 = ab*2*c + max(0, x-ab)*a + max(0, y-ab)*b
print(min(ans1, ans2, ans3, ans4, ans5))

Submission status: Wrong Answer

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

ans2 = x*a + y*b

ab = max(x, y)//2 * 2
ans3 = ab*2*c + max(0, x-ab)*a + max(0, y-ab)*b

ab = max(x, y)/2 * 2
ans4 = ab*2*c + max(0, x-ab)*a + max(0, y-ab)*b
print(min(ans1, ans2, ans3, ans4))