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

Submission status: Accepted

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

ans_1 = X * A + Y * B
if X > Y :
    ans_2 = Y * 2 * C + (X-Y) * A
else :
    ans_2 = X * 2 * C + (Y-X) * B
ans_3 = max(X, Y) * 2 * C

print(min(ans_1,ans_2,ans_3))

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

def main():
    A, B, C, X, Y = map(int, input().split())
    max_c = max([X, Y]) * 2
    min_cost = float("inf")
    for n_c in range(0, max_c + 1, 2):
        n_a = max(X - n_c / 2, 0)
        n_b = max(Y - n_c / 2, 0)
        cost = A * n_a + B * n_b + C * n_c
        if cost < min_cost:
            min_cost = cost
    print(int(min_cost))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

A,B,C,X,Y = list(map(int, input().rstrip().split()))
#----------
remain_X=X
remain_Y=Y
num_AB=0
cost=0

if (C*2) < (A+B):
    num_AB += min(X,Y) * 2
    remain_X -= num_AB / 2
    remain_Y -= num_AB / 2

if (C*2) < A and A > B and remain_X > 0:
    num_AB += remain_X * 2
    remain_X = 0
    remain_Y -= num_AB / 2
    
    if remain_Y < 0:
        remain_Y = 0

if (C*2) < B and A < B and remain_Y > 0:
    num_AB += remain_Y * 2
    remain_X -= num_AB / 2
    remain_Y = 0
    
    if remain_X < 0:
        remain_X = 0
###
if (C*2) < A and remain_X > 0:
    num_AB += remain_X * 2
    remain_X = 0
    remain_Y -= num_AB / 2
    
    if remain_Y < 0:
        remain_Y = 0
        
if (C*2) < B and remain_Y > 0:
    num_AB += remain_Y * 2
    remain_X -= num_AB / 2
    remain_Y = 0
    
    if remain_X < 0:
        remain_X = 0


cost = (remain_X * A) + (remain_Y * B) + (num_AB * C)
print(int(cost))

Submission status: Accepted

Solution code:
A, B, C, X, Y = map(int, input().split())
# print("{},{},{},{},{}".format(A,B,C,X,Y))
cost = 0
if A+B >= 2*C:
    if X>Y:
#         print("{},{}".format(X,Y))
        cost += C*Y*2
        X -= Y
        Y -= Y
#         print("{},{}".format(X,Y))

    else:
        cost += C*X*2
        Y -= X
        X -= X
#         print("{},{}".format(X,Y))
    if X>0 and A > 2*C:
        cost += X*C*2
    elif X>0 and A <= 2*C:
        cost += X*A
    elif Y>0 and B > 2*C:
        cost += Y*C*2
    elif Y>0 and B <= 2*C:
        cost += Y*B
else:
    cost += X*A + B*Y

print(cost)

Submission status: Accepted

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

ans = float('inf')
for c in range(max(X,Y)+1):
    tmp = C*c*2 + max(0,X-c)*A + max(0,Y-c)*B
    ans = min(ans, tmp)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

# Aピザ, Bピザのみ
ans1 = A * X + B * Y

# ABピザのみ
ans2 = C * max(X, Y) * 2

# ABピザとAピザ, Bピザ
if X > Y:
    ans3 = C * Y * 2 + A * (X - Y)
else:
    ans3 = C * X * 2 + B * (Y - X)

print(min(ans1, ans2, ans3))

Submission status: Accepted

Solution code:
A, B, C, X, Y = [int(x) for x in input().split()]
mon1 = X * A + Y * B
mon2 = 2 * C * max(X, Y)
mon3 = 2 * C * min(X, Y)
mon3 += A * (max(X, Y) - min(X, Y)) if X >= Y else B * (max(X, Y)  - min(X, Y))
print(min(mon1, mon2, mon3))

Submission status: Accepted

Solution code:
A, B, C, X, Y = [int(x) for x in input().split()]
if A + B < 2 * C:
    print(A * X + B * Y)
else:
    money = 0
    if X == Y:
        money = 2 * X * C
    elif X > Y:
        money = 2 * Y * C
        if 2 * C < A:
            money += 2 * (X - Y) * C
        else:
            money += (X - Y) * A
    else:
        money = 2 * X * C
        if 2 * C < B:
            money += 2 * (Y - X) * C
        else:
            money += (Y - X) * B
    print(money)

Submission status: Accepted

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

min_count = min(X, Y)
max_count = max(X, Y)

p1 = (C * min_count) * 2 + A * (X - min_count) + B * (Y -min_count)
p2 = A * X + B * Y
p3 = (C * max_count) * 2

print(min(p1, p2, p3))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [input() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [int(input()) for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def roundUp(a, b):
        return -(-a // b)

    @staticmethod
    def toUpperMultiple(a, x):
        return Math.roundUp(a, x) * x

    @staticmethod
    def toLowerMultiple(a, x):
        return (a // x) * x

    @staticmethod
    def nearPow2(n):
        if n <= 0:
            return 0
        if n & (n - 1) == 0:
            return n
        ret = 1
        while(n > 0):
            ret <<= 1
            n >>= 1
        return ret

    @staticmethod
    def isPrime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


MOD = int(1e09) + 7


def main():
    # sys.stdin = open("sample.txt")
    A, B, C, X, Y = Scanner.map_int()
    ans = 0
    C *= 2
    if A + B >= C:
        n = min(X, Y)
        X -= n
        Y -= n
        ans += C * n
    if A <= C:
        ans += X * A
    else:
        ans += X * C
    if B <= C:
        ans += Y * B
    else:
        ans += Y * C
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

C2 = C * 2
diff = abs(X - Y)

ans = 0


if C2 > A + B:
  ans = (A * X) + (B * Y)

elif C2 <= A + B:
  if X > Y:
    ans = min(C2 * Y + A * diff,C2 * X)

  else:
    ans = min(C2 * X + B * diff,C2 * Y)
    
print(ans)

Submission status: Accepted

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

for i in range(10**5+1):
    tmp = i*2*c
    if i>=x:
        pass
    else:
        tmp += (x-i)*a
    if i>=y:
        pass
    else:
        tmp += (y-i)*b
    if ans > tmp:
        ans = tmp

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

#ApかBp買ってからABpにする
ans = a*x+b*y
for i in range(1, max(x, y)+1):
    if i <= min(x, y):
        ans = min(ans, ans-a-b+2*c)
    else:
        if x < y:
            ans = min(ans, ans-b+2*c)
        else:
            ans = min(ans, ans-a+2*c)
print(ans)

Submission status: Accepted

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

C_max = max(X, Y)
min_count = float('inf')

for i in range(0,C_max*2+1,2):
    count = 0
    count += A * max(int(X-i/2),0)
    count += B * max(int(Y-i/2),0)
    count += C * i
    if min_count > count:
        min_count = count

print(min_count)

Submission status: Accepted

Solution code:
a_price, b_price, c_price, X, Y = list(map(int, input().split()))

total_price_1 = 0
total_price_2 = 0
diff = 0

# A, B <= 2 * C ならAとBそれぞれ買ったほうが安い
# それ以外だとCを可能な限り買った方が安い
# Cがすごく安いと, 過剰な枚数買っても安くなる場合とそうでない場合がある

if a_price + b_price < c_price * 2:
    total_price_1 = a_price * X + b_price * Y
    print(total_price_1)
else:
    if X > Y:
        total_price_1 = (c_price * 2) * X
        total_price_2 = (c_price * 2) * Y + a_price * (X - Y)
    else:
        total_price_1 = (c_price * 2) * Y
        total_price_2 = (c_price * 2) * X + b_price * (Y - X)

    print(min([total_price_1, total_price_2]))

Submission status: Accepted

Solution code:
a_price, b_price, c_price, X, Y = list(map(int, input().split()))

a_num = X
b_num = Y

total_price_1 = 0
total_price_2 = 0
max_pizza = 0
diff = 0

if a_price + b_price < c_price * 2:
    total_price_1 = a_price * X + b_price * Y
    print(total_price_1)
else:
    if X > Y:
        total_price_1 = (c_price * 2) * X
    else:
        total_price_1 = (c_price * 2) * Y

    if X > Y:
        total_price_2 += (c_price * 2) * Y
        diff = X - Y
        total_price_2 += a_price * diff
    else:
        total_price_2 += (c_price * 2) * X
        diff = Y - X
        total_price_2 += b_price * diff

    # if a_num >= X and b_num >= Y:
    #     if diff > 0:
    #         total_price += a_price * diff
    #     elif diff < 0:
    #         total_price += b_price * abs(diff)

    # for i in range(diff):
    #     if X - Y > 0:
    #      if total_price_1 > total_price - (c_price * 2) * (i + 1) + a_price:
    #             total_price = total_price - (c_price * 2) + a_price
    #     elif diff < 0:
    #         if total_price > total_price - (c_price * 2) + b_price:
    #             total_price = total_price - (c_price * 2) + b_price
    print(min([total_price_1, total_price_2]))

Submission status: Accepted

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

## min(Ax + By + Cz) = min((A+0.5C)x + (B+0.5C)y)
# Xyen = Ai + 2Cj, Yyen = Bk + 2Cj, X = i +2j, Y = k + 2j
# Xyen + Yyen = AX + BY + 2(C-A)j + 2(C-B)j, jを求めればok?

# l = []
# for j in range(max(X,Y)+1):
#     if j <= X+Y:
#         l.append(A*X + B*Y + (C-A*0.5-B*0.5)*j)

# print(int(min(l)))

X1 = X
Y1 = Y
price = []
for i in range(0, max(X,Y)+1):
    price.append(max(0,(X1-i))*A+max(0,(Y1-i))*B+2*i*C) 
print(min(price))

Submission status: Accepted

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

sum_ = 0
if AB <= (A+B)/2:
  if X >= Y:
    sum_ = min(AB*Y*2 + A*(X-Y), AB*X*2)
  else:
    sum_ = min(AB*X*2 + B*(Y-X), AB*Y*2)
else:
  sum_ = A*X + B*Y

print(sum_)

Submission status: Accepted

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

ans = 100000000000000000000000000

AB = C * 2

for ab in range(100000 + 1):
  x = 0
  if X - ab > 0:
    x = X - ab
  
  y = 0
  if Y - ab > 0:
    y = Y - ab
  
  d = (x * A) + (y * B) + (AB * ab)

  if ans > d:
    ans = d

print(ans)

Submission status: Accepted

Solution code:
a,b,mix,n_a,n_b=input().rstrip().split()
a=int(a)
b=int(b)
mix=int(mix)
n_a=int(n_a)
n_b=int(n_b)
x=[n_a,n_b]
fee=a*n_a+b*n_b
fee_a=2*mix*max(x)
fee_mix=0
if n_a>=n_b:
    fee_mix=n_b*2*mix+(n_a-n_b)*a
else:
    fee_mix=n_a*2*mix+(n_b-n_a)*b
print(min(fee,fee_a,fee_mix))

Submission status: Accepted

Solution code:
A,B,C,X,Y=map(int,input().split())
price=[]
for i in range(100000+1):
    price.append(i*2*C+max(0,X-i)*A+max(0,Y-i)*B)

print(min(price))

Submission status: Accepted

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

def Cal(A, B, C, D, E): 
    if (A+B) >= 2*C:
        ans = min(2*C*E + A*(D-E), 2*C*D)
    else:
        ans = A*D+B*E
    return ans


if x >= y:
    ans = Cal(a, b, c, x, y)
else:
    ans = Cal(b, a, c, y, x)

print(ans)

Submission status: Accepted

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

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

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

print(ans)

Submission status: Accepted

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

minf = sys.maxsize
X1 = X
Y1 = Y


for i in range(0, max(X,Y)+1):
    price = max(0,(X1-i))*A+max(0,(Y1-i))*B+2*i*C
    if minf > price:
        minf = price


print(minf)

Submission status: Accepted

Solution code:
# coding: utf-8
# Here your code

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

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

print(result)

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

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

result = []

n = A*X + B*Y 
result.append(n) 

n = C*min([X,Y])*2
if X >= Y:
    n += (X-Y)*A 
else:
    n += (Y-X)*B 
result.append(n) 

n = C*max(X,Y)*2
result.append(n)

print(min(result))

Submission status: Accepted

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

Submission status: Accepted

Solution code:


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

    range_i = range(0, 100001)
    min_z = 1000000000
    for i in range_i:
        z = i * (2 * c) + (max(0, x - i) * a) + (max(0, y - i) * b)
        if z < min_z:
            min_z = z
    print(min_z)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

print(money)

Submission status: Accepted

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

# 小さい方
z = min(x, y)
price = 0
# 単品で買ったほうが安い場合
if a + b <= 2 * c:
  price += z * (a + b)
  aa += z
  bb += z
else:
  price += z * 2 * c
  cc += 2 * z

# 残り
if x > y:
  # aの方が安い場合
  if a <= 2 * c:
    price += (x - y) * a
    aa += x - y
  else:
    price += (x - y) * 2 * c
    cc += 2 * (x - y)
else:
  # bの方が安い場合
  if b <= 2 * c:
    price += (y - x) * b
    bb += y - x
  else:
    price += (y - x) * 2 * c
    cc += 2 * (y - x)

# print(aa, bb, cc)
print(price)

Submission status: Accepted

Solution code:
a,b,c,x,y=map(int,input().split())
s = []
for i in range(max(x,y)+1):
    xs=x-i
    ys=y-i
    if xs <= 0:
        xs=0
    if ys <= 0:
        ys=0
    s.append(a*xs+b*ys+c*2*i)
print(min(s))

Submission status: Accepted

Solution code:
a, b, c, x, y = map(int, input().split())
total = a*x+b*y
for i in range(0, max(x,y)*2+2, 2):
  C = c*i
  A = max((x-i//2),0)*a
  B = max((y-i//2),0)*b
  total = min(total, A+B+C)
print(total)

Submission status: Accepted

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

for countC in range(1, 2*(X+Y)):
    if countC % 2 == 0:
        countA -= 1
        if countA < 0:
            countA = 0
        countB -= 1
        if countB < 0:
            countB = 0
        tmpPrice = countA * A + countB * B + countC * C
        if tmpPrice < price:
            price = tmpPrice
print(price)

Submission status: Accepted

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

min_cost = 1e10
for a in range(X+1):
    c = (X-a)*2
    left_b = max(0, Y - (X-a))
    cost = a*A+round(left_b)*B+c*C
    if cost < min_cost:
        min_cost = cost
    # 残り全部をABピザで賄う場合
    left_b = max(X-a, Y)
    cost = a*A + left_b*2*C
    if cost < min_cost:
        min_cost = cost
print(min_cost)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a, b, c, x, y = [int(x) for x in input().split()]

c_list = list(range(max(x, y) * 2, -1, -2))
min_cost = max(x, y) * 2 * c

for index, numc in enumerate(c_list):
	numa = int(x - numc/2) if x > numc / 2 else 0
	numb = int(y - numc/2) if y > numc / 2 else 0
	cost = numa * a + numb * b + numc * c
	if cost < min_cost:
		min_cost = cost
		
print(min_cost)

Submission status: Accepted

Solution code:
A, B, C, X, Y = [int(i) for i in input().split()]

T = abs(X-Y)*B if X < Y else abs(X-Y)*A
T1 = A*X + B*Y
T2 = max(X, Y)*2*C
T3 = min(X, Y)*2*C + T

print(min(T1, T2, T3))

Submission status: Accepted

Solution code:
A, B, C, X, Y = [int(i) for i in input().split()]

# A, B バラ買いパターン
total1 = A * X + B * Y

# A, B どちらか必要な量を超えるパターン
total2 = 2 * C * max(X, Y)

# 必要最小限の C セットを買い, 足りない分はバラ買いパターン
P = B if X < Y else A
total3 = 2 * C * min(X, Y) + P * abs(X - Y)

# 上記のうちで一番安いもの
ret = min(total1, min(total2, total3))
print(ret)

Submission status: Accepted

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


def solve(A: int, B: int, C: int, X: int, Y: int):
    ans = 1e20
    for i in range(max(X, Y) + 1):
        a = max(X-i, 0)
        b = max(Y-i, 0)
        c = 2*i
        ans = min(ans, A*a + B*b + C*c)
    return ans

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

Submission status: Accepted

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

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

mi = min(x, y)
ma = max(x, y)
print(min(c*mi*2+a*(x-mi)+b*(y-mi), c*ma*2, a*x+b*y))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b,c,x,y=map(int,input().split())
p_=a*x+b*y
for i in range(10**5+1):
  p=i*2*c+a*max(0,x-i)+b*max(0,y-i)
  if p<p_:
    p_=p
print(p_)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
a,b,ab,x,y = map(int,input().split())
total = 0
if (a+b)/2 > ab :
	m = max(x,y)
	n = min(x,y)
	total += n*ab*2
	z = 0
	s = 0
	t = 0
	if x > y :
		z = x-y
		s = z*a
	elif y>x :
		z = y-x
		s = z*b
	t = z*ab*2
	total += s if s<t else t

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

Submission status: Accepted

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

# A, B両方のピザの購入
if a+b<2*c:
    ans+=min(x,y)*(a+b)
else:
    ans+=min(x,y)*2*c

# A又はBの残りのピザを購入
if x>y:
    ans+=min(a,2*c)*(x-y)
else:
    ans+=min(b,2*c)*(y-x)

print(ans)

Submission status: Accepted

Solution code:
A, B, C, X, Y = map(int, input().split())
min_price = A * X + B * Y
AB = 2 * C
for i in range(10**5 + 1):
    p = i * AB + max(0, X - i) * A + max(0, Y - i)  * B   
    if p < min_price:
        min_price = p           

print(min_price)

Submission status: Accepted

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

if cnt == X:
    for i in range(Y + 1):
        p = A * (X - i) + B * (Y -i) + C * i * 2
        if p < min_price:
            min_price = p
    for i in range(Y + 2, cnt + 1):
        p = A * (X - i) + C * i * 2
        if p < min_price:
            min_price = p
elif cnt == Y:
    for i in range(X + 1):
        p = A * (X - i) + B * (Y -i) + C * i * 2
        if p < min_price:
            min_price = p
    for i in range(X + 2, cnt + 1):
        p = B * (Y - i) + C * i * 2
        if p < min_price:
            min_price = p                   

print(min_price)

Submission status: Accepted

Solution code:
a,b,c,x,y=(int(x) for x in input().split())
m=float('inf')
for i in range(100001):
  n=2*c*i+max(0,x-i)*a+max(0,y-i)*b
  if n<m:
    m=n
print(m)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:

import sys
def input():
	return sys.stdin.readline().strip()

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

if 2*C < A and 2*C < B:
	print(max(X, Y)*2*C)
	#print(1)
elif 2*C < A and 2*C >= B:
	if X >= Y:
		print(max(X, Y) * 2 * C)
		#print(2)
	else:
		print(X*2*C + (Y - X)*B)
		#print(3)
elif 2*C >= A and 2*C < B:
	if X <= Y:
		print(max(X, Y) * 2 * C)
		#print(4)
	else:
		print(Y*2*C + (X - Y)*A)
		#print(5)
elif 2*C < A + B and X <= Y:
	print(2*C*X + (Y - X)*B)
	#print(6)
elif 2*C < A + B and X >= Y:
	print(2 * C * Y + (X - Y) * A)
	#print(7)
else:
	print(A*X + B*Y)
	#print(8)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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


if s_c < s_ab:
    if x < y:
        price1 = s_c * x + b * (y-x)
        price2 = s_c * y
        print(min(price1, price2))
    elif x > y:
        price1 = s_c * x
        price2 = s_c * y + a * (x-y)
        print(min(price1, price2))
    else:
        print(s_c * x)
elif s_c >= s_ab:
    print(a * x + b * y)

Submission status: Accepted

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

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

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

print(price)

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

Submission status: Accepted

Solution code:
a, b, c, x, y = map(int, input().split())
min = 999999999999999999999999999999999999
for i in range(100001):
    price = max(0, x - i) * a + max(0, y - i) * b + (i * 2 * c)
    if price < min:
        min = price
print(min)

Submission status: Accepted

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

ans = 0

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

print(ans)

Submission status: Accepted

Solution code:
I = input().split(" ")
A, B, C, X, Y = int(I[0]), int(I[1]), int(I[2]), int(I[3]), int(I[4])
AB = C * 2
if A + B >= AB:
    if A >= AB and B >= AB:
        if X >= Y:
            print(X * AB)
        else:
            print(Y * AB)
    elif A >= AB and B <= AB:
        if X >= Y:
            print(X * AB)
        else:
            print(X * AB + (Y - X) * B)
    elif A <= AB and B >= AB:
        if X >= Y:
            print((X - Y) * A + Y * AB)
        else:
            print(Y * AB)
    else:
        if X >= Y:
            print((X - Y) * A + Y * AB)
        else:
            print(X * AB + (Y - X) * B)

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

Submission status: Accepted

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

if A + B < C * 2:
    a += (A + B) * min(X, Y)
else:
    a += 2 * C * min(X, Y)

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

Submission status: Accepted

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

lst = []

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

if X > Y:
    a = C*2*Y + (X-Y)*A
else:
    a = C*2*X + (Y-X)*B
lst.append(a)

print(min(lst))

Submission status: Accepted

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

ans = 0

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

Submission status: Accepted

Solution code:
A, B, C, X, Y = map(int, input().split(" "))
AB = 2 * C
if AB > A + B:
  case = 1
else:
  case = 2

if case == 1:
  print(A * X + B * Y)
  exit()

if case == 2:
  if X > Y:
    Z = Y
    X = X - Y
    Y = 0
    if AB < A:
      Z = Z + X
      X = 0
  else:
    Z = X
    Y = Y - X
    X = 0
    if AB < B:
      Z = Z + Y
      Y = 0
print(A * X + B * Y + AB * Z)

Submission status: Accepted

Solution code:
A,B,C,X,Y=map(int,input().split())
ans=A*X+B*Y
for z in range (0,100001):
  J=(max(0,X-z))*A+(max(0,Y-z))*B+2*C*z
  if ans > J:
    ans = J
    
print(ans)

Submission status: Accepted

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

price=a*x+b*y

for k in range(0,10**5+1):
  s=2*c*k+max(0,x-k)*a+max(0,y-k)*b
  if price>s :
    price=s

print(price)

Submission status: Accepted

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

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

q = A*X + B*Y

print(min(p, q))

Submission status: Accepted

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