Problem:


Score : 300 points

Problem Statement

"Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively.

Nakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas.

Constraints

1 ≤ A, B, C ≤ 5000

1 ≤ X, Y ≤ 10^5

All values in input are integers.

Input

Input is given from Standard Input in the following format:

A B C X Y

Output

Print the minimum amount of money required to prepare X A-pizzas and Y B-pizzas.

Sample Input 1

1500 2000 1600 3 2

Sample Output 1

7900

It is optimal to buy four AB-pizzas and rearrange them into two A-pizzas and two B-pizzas, then buy additional one A-pizza.

Sample Input 2

1500 2000 1900 3 2

Sample Output 2

8500

It is optimal to directly buy three A-pizzas and two B-pizzas.

Sample Input 3

1500 2000 500 90000 100000

Sample Output 3

100000000

It is optimal to buy 200000 AB-pizzas and rearrange them into 100000 A-pizzas and 100000 B-pizzas. We will have 10000 more A-pizzas than necessary, but that is fine.



Sample input:
1500 2000 1600 3 2


Sample output:
7900

Submission status: Accepted

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

arr = []
for i in range(10**5+1):
    arr.append(i*2*c + max(0,x-i)*a + max(0,y-i)*b)

print(min(arr))

Submission status: Accepted

Solution code:
#coding: utf-8
import math
import heapq
import bisect
import numpy as np
from collections import Counter
#from scipy.misc import comb

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

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

print(ans)

Submission status: Accepted

Solution code:
def buy_ab(cost_a, cost_b, cost_ab, target_a, target_b, target_ab):
    target_a = max(0, target_a - target_ab // 2)
    target_b = max(0, target_b - target_ab // 2)
    return cost_ab * target_ab + cost_a *target_a  + cost_b * target_b


def main():
    cost_a, cost_b, cost_ab, target_a, target_b = map(int, input().split(" "))
    buy_whole = cost_a * target_a + cost_b * target_b
    print(min(buy_ab(cost_a, cost_b, cost_ab, target_a, target_b, min(target_b, target_a) * 2),
              buy_ab(cost_a, cost_b, cost_ab, target_a, target_b, max(target_b, target_a) * 2),
              buy_whole))


if __name__ == '__main__':
    main()

Submission status: Accepted

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

ans1=a*x+b*y
ans2=c*2*x+b*(y-x) if y>=x else a*(x-y)+c*2*y
ans3=max(x,y)*2*c
print(min(ans1,ans2,ans3))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

if x<y:
    #print((y-x)*b+x*ab*2)
    print(min((y-x)*b+x*ab*2 , a*x+b*y , y*ab*2))
else:#x>=y
    #print((x-y)*a+y*ab*2)
    print(min((x-y)*a+y*ab*2,a*x+b*y , x*ab*2))

Submission status: Accepted

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

    n_c = min(x, y)

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


if __name__ == "__main__":
    resolve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
#input
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
a,b,c,x,y = map(int,input().split())
if 2*c <= a and 2*c <= b:
    print(max(x,y)*2*c)
elif 2*c <= a:
    print(x*2*c + max(0,y-x)*b)
elif 2*c <= b:
    print(y*2*c + max(0,x-y)*a)
elif 2*c <= a+b:
    if y < x:
        print(y*2*c + (x-y)*a)
    else: print(x*2*c + (y-x)*b)
else:
    print(a*x + b*y)

Submission status: Accepted

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

Submission status: Accepted

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

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

else:
    ans += A*X
    ans += B*Y

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
piza = list(map(int,input().split()))
x = piza[0] * piza[3] + piza[1] * piza[4] #普通に買うパターン
y = piza[2] * 2 * max(piza[3],piza[4])

if piza[3] >= piza[4]:
    z = piza[2] * (2 * piza[4]) + piza[0] * (piza[3] - piza[4])
else:
    z = piza[2] * (2 * piza[3]) + piza[1] * (piza[4] - piza[3])
print(min(x,y,z))

Submission status: Accepted

Solution code:
piza = list(map(int,input().split()))
x = piza[0] * piza[3] + piza[1] * piza[4]
y = piza[2] * 2 * max(piza[3],piza[4])
if piza[3] >= piza[4]:
	z = piza[2] * (2 * piza[4]) + piza[0]*(piza[3]-piza[4])
else:
	z = piza[2] * (2 * piza[3]) + piza[1]*(piza[4]-piza[3])
print(min(x,y,z))

Submission status: Accepted

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


main()

Submission status: Accepted

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

patb = c * (2 * max(x,y))

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

Submission status: Accepted

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


main()

Submission status: Accepted

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


main()

Submission status: Accepted

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

ans = A*X+B*Y
for i in range(max(X,Y)+1): #iはABピザの枚数
    a = max(X - i,0)
    b = max(Y - i,0)
    c = 2*i
    sum = A*a + B*b + C*c
    # print(a,b,c,sum)
    if sum < ans:
        ans = sum
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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 * X + (Y - X) * B)

    print(min(ans))


    

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
 
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()
nas = lambda: stdin.readline().split()

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

ans = 0
while x or y:
    if x and y:
        if a + b > c * 2:
            z = min(x, y)
            x -= z
            y -= z
            ans += c * 2 * z
        else:
            z = min(x, y)
            x -= z
            y -= z
            ans += (a + b) * z
    else:
        q = c * 2 * (x + y)
        if q <= a * x + b * y:
            ans += c * 2 * (x + y)
            x = 0
            y = 0
        if x:
            ans += a * x
            x = 0
        if y:
            ans += b * y
            y = 0

print(ans)

Submission status: Accepted

Solution code:
import sys
 
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()
nas = lambda: stdin.readline().split()

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b,c,x,y=map(int,input().split())
if a>=2*c and b>=2*c:
    print(max(x,y)*2*c)
elif a<2*c and b>=2*c:
    print(y*2*c + max(0,x-y)*a)
elif a>=2*c and b<2*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: Accepted

Solution code:
A, B, C, X, Y = map(int, input().split())
x, y = min(X,Y), max(X,Y)-min(X,Y)
D = [A,B][X<=Y]
if A+B <= C+C:
    ans = (A+B)*x+D*y
else:
    ans = (C+C)*x+min(D,C+C)*y
print(ans)

Submission status: Accepted

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

C2=C*2

if(A>C2 and B>C2):
    print(max(X,Y)*2*C)
    exit()

if(A>C2):
    t=X*2*C
    y=Y-X
    t+=max(0,y)*B
    print(t)
    exit()

if(B>C2):
    t=Y*2*C
    x=X-Y
    t+=max(0,x)*A
    print(t)
    exit()

if(A+B>C2):
    z=min(X,Y)
    t=z*2*C
    t+=(X-z)*A
    t+=(Y-z)*B
    print(t)
    exit()

print(A*X+B*Y)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(m)

Submission status: Accepted

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

if (A+B) <= 2*C: # 単品だけで購入
  print(X*A + Y*B)
else:
  # ABを買い残りを単品で補う
  if X >= Y:
    # ABでYは賄える
    print(min(X*2*C, Y*2*C + A*(X-Y)))
  else:
    # ABでXは賄える
    print(min(Y*2*C, X*(2*C)+B*(Y-X)))

Submission status: Accepted

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

# Cを買った個数とA、B単品で買った場合のコストを愚直に試す
total = 1<<60
for i in range(10**5+1):
  cost = 2*C*i + max(X-i, 0)*A + max(Y-i, 0)*B
  total = min(cost, total)

print(total)

Submission status: Accepted

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

Submission status: Accepted

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:
    a = min(a,c*2)
    print(memo2*a+memo1*chp)
else:
    b = min(b,c*2)
    print(memo2*b+memo1*chp)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

ret = A * X + B * Y
X -= 1
Y -= 1
Z = 2
while X >= 0 or Y >= 0:
    ret = min(ret, max(0, A * X) + max(0, B * Y) + C * Z)
    X -= 1
    Y -= 1
    Z += 2

print(ret)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
A,B,C,X,Y = [int(i) for i in input().split()]
money = A * X + B * Y
ans = money
m = min(X,Y)
M = max(X,Y)
d = M - m
if A + B > C * 2 :
    for i in range(m) :
        ans = ans -( A + B) + (2 * C)
    if m == X :
        if B * d > C * 2 * d :
            ans =ans - (B * d) + C * 2 * d
    else :
        if A * d > C * 2 * d :
            ans = ans -(A * d) + C * 2 * d
print(ans)

Submission status: Accepted

Solution code:
a,b,c,x,y = map(int, input().split())
cost = {x:a, y:b}
s = min(x,y) * c * 2 + abs(x - y) * cost[max(x,y)]
t = max(x,y) * c * 2
u = a * x + b * y

print(min([s, t, u]))

Submission status: Accepted

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

#貪欲で全てのケースを用意する。

ans = 0

ans += a*x + b*y

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

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

print(ans)

Submission status: Accepted

Solution code:
A,B,C,X,Y = map(int,input().split())
ABset = min(A+B,2*C)
Asgl = min(A,2*C)
Bsgl = min(B,2*C)
Z = min(X,Y)
Ans = ABset * Z
Ans += Asgl * (X - Z)
Ans += Bsgl * (Y - Z)
print(Ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

COMMON = min(X, Y)
P1 = (A * X) + (B * Y)
P2 = (COMMON * (C * 2) + (X - COMMON) * A + (Y - COMMON) * B)
P3 = (COMMON * (C * 2) + (X - COMMON) * (C*2) + (Y - COMMON) * B)
P4 = (COMMON * (C * 2) + (X - COMMON) * A + (Y - COMMON) * (C*2))
print(min(P1, P2, P3, P4))

Submission status: Accepted

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


# パターン1 Aを買いきってBを買う
ans1 = a*x + b*y
# パターン2 Aを買いきってABを買う
ans2 = a*x + 2*y*c
# パターン3 Bを買いきってABを買う
ans3 = b*y + 2*x*c
# パターン4 ABですべて買い切る
ans4 = max(x,y) * 2 * c
# パターン5 埋め合わせ
if x < y:
    ans5 = x * 2 * c + (y-x) * b 
else:
    ans5 = y * 2 * c + (x-y) * a

print(min(ans1,ans2,ans3,ans4,ans5))

Submission status: Accepted

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

D=min(A+B,2*C)

price=min(X,Y)*D

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

if X>Y:
   price+=Z*min(A,2*C)
elif X<Y:
   price+=Z*min(B,2*C)

print(price)

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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


print(min(sum,sum_ab,sum_a_b))

Submission status: Accepted

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


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

    return


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: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import exit

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

if a+b<2*c:
    print(x*a+y*b)
    exit()

ans = 0
if x>y:
    a,b = b,a
    x,y = y,x

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

Submission status: Accepted

Solution code:
import sys

a, b, c, x, y = map(int, sys.stdin.readline().split())

if x < y:
    x, y = y, x
    a, b = b, a

def main():

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

if __name__ == '__main__':
    ans = main()
    print(ans)

Submission status: Accepted

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

def foo(z):
    res = a*max(x-z//2, 0) + b*max(y-z//2, 0) + c*z
    #print (z, res)
    return res
candid = []
for z in range(max(x, y)*2+1):
    candid.append(foo(z))
print (min(candid))

Submission status: Accepted

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    A, B, C, X, Y = LI()
    if X > Y:
        X, Y = Y, X
        A, B = B, A
    money_a_b = X * A + Y * B
    money_b_c = (Y - X) * B + (2 * X) * C
    money_c = Y * 2 * C
    ans = min(money_a_b, money_b_c, money_c)
    print(ans)

main()

Submission status: Accepted

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

Submission status: Accepted

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

count = 0

ans1 = a*x + b*y
ans2 = 2*c*(min(x,y))
ans3 = 2*c*(max(x,y))

if x > y:
  ans2 += a*(x-y)
elif x < y:
  ans2 += b*(y-x)

print(min(ans1,ans2,ans3))

Submission status: Accepted

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

Submission status: Accepted

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

D = C * 2
p = []

if X > Y:
    p.append(D * Y + A * (X - Y))
else:
    p.append(D * X + B * (Y - X))

p.append(A * X + B * Y)
p.append(D * max(X, Y))

ans = min(p)

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b,c,x,y=map(int,input().split())
ans=0
m=min(x,y)
if a+b>=2*c: #Half and Half購入で安くなる可能性あるパターン
    # HaHをm枚買って残りHaH購入,または全部HaH購入,このいずれかしかあり得ない
    ans = min(2*c*m+a*(x-m)+b*(y-m), 2*c*max(x,y))
else:
    ans = a*x+b*y
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

    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: Accepted

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

Submission status: Accepted

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 * 2
#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: Accepted

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

Submission status: Accepted

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

main()

Submission status: Accepted

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

def main():
    (A,B,C,X,Y) = map(int,input().split())
    lim = max(X, Y)
    vmin = min(X, Y)
    minCost = 5000 * 10**5 * 2
    for t in range(lim+1):
        if t <= vmin:
            cost = (X - t) * A + (Y - t) * B + t * 2 * C
        elif X <= Y:
            cost = (Y - t) * B + t * 2 * C
        else:
            cost = (X - t) * A + t * 2 * C
        minCost = min(minCost, cost)
    print(minCost)
    

main()

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
A, B, C, X, Y = [int(x) for x in input().split()]
ans_notAB = A * X + B * Y
temp = min(X,Y)
ans_AB = 2 * temp * C
if X > Y:
    X -= Y
    ans_AB += min([X * A, 2 * X * C])
elif Y > X:
    Y -= X
    ans_AB += min([Y * B, 2 * Y * C])
print(min(ans_AB,ans_notAB))

Submission status: Accepted

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

cost = 0
if A + B > 2 * C:
    n_purchase_surplus = 2 * max(X, Y)
    cost_surplus = n_purchase_surplus * C
    if X >= Y:
        n_purchase = 2 * Y
        cost = n_purchase * C
        n_remaining = X - Y
        cost += n_remaining * A
    else:
        n_purchase = 2 * X
        cost = n_purchase * C
        n_remaining = Y - X
        cost += n_remaining * B
    # select minimum cost
    cost = min(cost_surplus, cost)
else:
    cost = (X * A) + (Y * B)
print(cost)

Submission status: Accepted

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

Submission status: Accepted

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 and x>y:
    ans = c*x*2
  elif a<=b and x<=y:
    ans = c*y*2
  elif a>b and x<=y:
    ans = c*x*2+b*(y-x)
  elif a<=b and x>y:
    ans = c*y*2+a*(x-y)
  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: Accepted

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