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

from sys import stdout
from bisect import bisect_left as binl
from copy import copy, deepcopy
from collections import defaultdict


mod = 1


def intin():
    input_tuple = input().split()
    if len(input_tuple) <= 1:
        return int(input_tuple[0])
    return tuple(map(int, input_tuple))


def intina():
    return [int(i) for i in input().split()]


def intinl(count):
    return [intin() for _ in range(count)]


def modadd(x, y):
    global mod
    return (x + y) % mod


def modmlt(x, y):
    global mod
    return (x * y) % mod


def lcm(x, y):
    while y != 0:
        z = x % y
        x = y
        y = z
    return x


def combination(x, y):
    assert(x >= y)

    if y > x // 2:
        y = x - y

    ret = 1

    for i in range(0, y):
        j = x - i
        i = i + 1

        ret = ret * j
        ret = ret // i

    return ret


def get_divisors(x):
    retlist = []
    for i in range(1, int(x**0.5) + 3):
        if x % i == 0:
            retlist.append(i)
            retlist.append(x // i)
    return retlist


def get_factors(x):
    retlist = []
    for i in range(2, int(x**0.5) + 3):
        while x % i == 0:
            retlist.append(i)
            x = x // i
    retlist.append(x)
    return retlist


def make_linklist(xylist):
    linklist = {}
    for a, b in xylist:
        linklist.setdefault(a, [])
        linklist.setdefault(b, [])
        linklist[a].append(b)
        linklist[b].append(a)
    return linklist


def calc_longest_distance(linklist, v=1):
    distance_list = {}
    distance_count = 0
    distance = 0
    vlist_previous = []
    vlist = [v]
    nodecount = len(linklist)

    while distance_count < nodecount:
        vlist_next = []
        for v in vlist:
            distance_list[v] = distance
            distance_count += 1
            vlist_next.extend(linklist[v])
        distance += 1
        vlist_to_del = vlist_previous
        vlist_previous = vlist
        vlist = list(set(vlist_next) - set(vlist_to_del))

    max_distance = -1
    max_v = None
    for v, distance in distance_list.items():
        if distance > max_distance:
            max_distance = distance
            max_v = v

    return (max_distance, max_v)


def calc_tree_diameter(linklist, v=1):
    _, u = calc_longest_distance(linklist, v)
    distance, _ = calc_longest_distance(linklist, u)
    return distance


class UnionFind:

    def __init__(self, n):
        self.parent = [i for i in range(n)]

    def root(self, i):
        if self.parent[i] == i:
            return i
        self.parent[i] = self.root(self.parent[i])
        return self.parent[i]

    def unite(self, i, j):
        rooti = self.root(i)
        rootj = self.root(j)
        if rooti == rootj:
            return
        if rooti < rootj:
            self.parent[rootj] = rooti
        else:
            self.parent[rooti] = rootj

    def same(self, i, j):
        return self.root(i) == self.root(j)


###############################################################################


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

    if c * 2 >= a + b:
        print(a * x + b * y)
        return

    xy = min(x, y)

    if a <= c * 2 and b <= c * 2:
        print((x - xy) * a + (y - xy) * b + xy * c * 2)
        return

    if b <= c * 2:
        print((x - xy) * c * 2 + (y - xy) * b + xy * c * 2)
        return

    if a <= c * 2:
        print((x - xy) * a + (y - xy) * c * 2 + xy * c * 2)
        return

    xy = max(x, y)
    print(xy * c * 2)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

min_cost = 10000000000
for i in range(max(x, y) + 1):
    cost = 2 * c * i + max(0, a * (x - i)) + max(0, b * (y - i))

    if min_cost > cost:
        min_cost = cost
print(min_cost)

Submission status: Accepted

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

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

if c*2 < a:#cがaよりお得な場合
    if c*2 < b:#cがbよりお得な場合
        ans = c*2*min(x,y) + (max(x,y) - min(x,y))*c*2
    else:#cがaよろお得かつbよりお得でない
        if x >= y:#aのほうが買う量が多い
            ans = c*2*x
        else:#bの方が買う量が多い
            ans = c*2*x + b*(y-x)
elif c*2 < b:#cがbよりお得な場合
    if c*2 > a:#cがaよりお得でない場合
        if x <= y:#bの方が買う量が多い
            ans = c*2*y
        else:#aの方が買う量が多い
            ans = a*(x-y) + c*2*y
else:
    ans1 = a*x + b*y
    if x <= y:
        ans2 = c*2*x + b*(y-x)
    elif y < x:
        ans2 = c*2*y + a*(x-y)
    ans = min(ans1,ans2)

print(ans)

Submission status: Accepted

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

for i in range(max(x+1, y+1)):
    tmp = c*i*2
    if i < x:
        tmp += a*(x-i)
    if i < y:
        tmp += b*(y-i)
    ans.append(tmp)

print(min(ans))

Submission status: Accepted

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

price1 = a*x + b*y


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

print(min(price1,price2,price3))

Submission status: Accepted

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

Submission status: Accepted

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

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

if c*2 < a:#cがaよりお得な場合
    if c*2 < b:#cがbよりお得な場合
        ans = c*2*min(x,y) + (max(x,y) - min(x,y))*c*2
    else:#cがaよろお得かつbよりお得でない
        if x >= y:#aのほうが買う量が多い
            ans = c*2*x
        else:#bの方が買う量が多い
            ans = c*2*x + b*(y-x)
elif c*2 < b:#cがbよりお得な場合
    if c*2 > a:#cがaよりお得でない場合
        if x <= y:#bの方が買う量が多い
            ans = c*2*y
        else:#aの方が買う量が多い
            ans = a*(x-y) + c*2*y
else:
    ans1 = a*x + b*y
    if x <= y:
        ans2 = c*2*x + b*(y-x)
    elif y < x:
        ans2 = c*2*y + a*(x-y)
    ans = min(ans1,ans2)

print(ans)

Submission status: Accepted

Solution code:
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LS()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    return

#B
def B():
    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    a,b,c,X,Y = LI()
    ans = float("inf")
    for z in range(300001):
        if z%2 == 0:
            m = c*z
            x = z//2
            y = z//2
            m += a*max(0,X-x)
            m += b*max(0,Y-y)
            if m < ans:
                ans = m
    print(ans)
    return

#G
def G():
    n = I()
    x = LI()
    f = [(i,x[i]) for i in range(n)]
    f.sort(key = lambda x:x[1])
    g = [(f[i][0],i) for i in range(n)]
    g.sort(key = lambda x:x[0])
    for i in range(n):
        if g[i][1] < n//2:
            print(f[n//2][1])
        else:
            print(f[n//2-1][1])
    return

#H
def H():
    return

#I
def I_():
    return

#J
def J():
    return

#Solve
if __name__ == "__main__":
    F()

Submission status: Accepted

Solution code:
import numpy as np

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

value = [A, B]
n_pizza = [X, Y]

# 買う手法は次の3通りしかない
# 全てAとB単品で揃える場合
price_1 = A * X + B * Y
# 全てCで揃える場合
price_2 = 2 * C * max(X, Y)
# 少ない方までCで買って、残りは単品という場合
idx_more_to_buy = n_pizza.index(max(n_pizza))
price_3 = 2 * C * min(X, Y) + value[idx_more_to_buy] * (n_pizza[idx_more_to_buy] - min(X, Y))

ans = min(price_1, price_2, price_3)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

p1 = A * X + B * Y
p2 = max(X, Y) * 2 * C
p3 = min(X, Y) * 2 * C + ((Y - X) * B if (X < Y) else (X - Y) * A)

print(min([p1, p2, p3]))

Submission status: Accepted

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


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

print(ans)

Submission status: Accepted

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


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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

ans=a*x+b*y
for ci in range(max(x,y)+1):
    sumc = 2*ci*c
    sumc += (x-ci)*a if (x-ci)>0 else 0
    sumc += (y-ci)*b if (y-ci)>0 else 0
    ans=min(ans,sumc)

print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
from collections.abc import Iterable
from math import *
from itertools import *
from collections import *
from functools import *
from operator import *
try:
    from math import gcd
except Exception:
    from fractions import gcd


def solve(A: int, B: int, C: int, X: int, Y: int):
    a = A * X + B * Y
    minv = min(X, Y)
    b = C * 2 * minv + A * (X - minv) + B * (Y - minv)
    c = 2 * max(X, Y) * C

    return min(a, b, c)


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
    result = solve(A, B, C, X, Y)
    if isinstance(result, Iterable):
        result = '\n'.join([str(v) for v in result])
    print(result)

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

Submission status: Accepted

Solution code:
import sys, os

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    a,b,c, x,y = f()
    ans = 0
    if 2*c <= a+b:
        ans += 2*c*min(x,y)
    else:
        ans += (a+b)*min(x,y)
    
    mxy = min(x,y)
    x -= mxy
    y -= mxy

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


solve()

Submission status: Accepted

Solution code:
def main():
    a_price, b_price, ab_price, a_num, b_num = map(int, input().split())
    chukan_price = (a_price + b_price) / 2
    min_num = min(a_num, b_num)

    ans = 0

    if chukan_price > ab_price:
        ans += min_num * 2 * ab_price
        a_num -= min_num
        b_num -= min_num
        # print(ans, a_num, b_num)
        if a_price > 2 * ab_price:
            ans += a_num * 2 * ab_price
        else:
            ans += a_num * a_price
        if b_price > 2 * ab_price:
            ans += b_num * 2 * ab_price
        else:
            ans += b_num * b_price
    else:
        ans += a_num * a_price
        ans += b_num * b_price

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools
A,B,C,X, Y = list(map(int,input().split(" ")))
C2 = C * 2
ans = 0

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



if A > C2:
    if B < C2:
        b_maisu = max(0,Y-X)
        ans += (X *  C2) + b_maisu * B


    else:
        ans += (max(X,Y)*C2)

elif A < C2:
    if B < C2:
        ans += A*X + Y * B
    else:
        a_maisu = max(0,X-Y)
        ans += (Y *  C2) + a_maisu * A

print(ans)

Submission status: Accepted

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

ave = (A+B)//2
#個別で買う or 組み合わせて不足分を買う or 組み合わせて余る　

ans1 = A*X + B * Y

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

ans3 = max(X,Y)*C*2

print(min(ans1,ans2,ans3))

Submission status: Accepted

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

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

Submission status: Accepted

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

price1 = a*x+b*y

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

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

print(min(price1,price2,price3))

Submission status: Accepted

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

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

Submission status: Accepted

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

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

m = 10 ** 18

for i in range(max(X, Y) + 1):
    a = A * (X - i)
    b = B * (Y - i)
    c = C * i * 2

    point = 0
    for v in [a, b, c]:
        if v > 0:
            point += v

    m = min(m, point)

print(m)

Submission status: Accepted

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

MA, MI = max(X,Y), min(X,Y)
ans = 2 * C * MA

if X != Y:
    for i in range(MA-MI):
        if X > Y:
            tmp = ans - 2*C + A
        else:
            tmp = ans - 2*C + B
        ans = min(ans,tmp)
        
for j in range(MI):
    tmp = ans - 2*C + A + B
    ans = min(ans,tmp)

print(ans)

Submission status: Accepted

Solution code:


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


def submit():
    a, b, c, x, y = read_input()


    # ABピザをmin(x,y)まで買い、あとは個別
    p1 = 0
    if x < y:
        ab_n = 2 * x
        b_n = y - x
        p1 = b*b_n + ab_n*c
    else:
        ab_n = 2 * y
        a_n = x - y
        p1 = a*a_n + ab_n*c

    # A, Bを別々に買ったほうがいい
    p2 = a*x + b*y

    # 全部ABピザ
    p3 = c * max(x, y)*2

    print(min(p1, p2, p3))

if __name__ == '__main__':
    submit()

Submission status: Accepted

Solution code:
from math import ceil
A, B, C, X, Y = map(int, input().split())
ans = float('inf')

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

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

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:
    c = min(X, Y)
    x = X-c
    y = Y-c
    ans = 2*C*c +min(A*x+B*y, 2*C*x+2*C*y)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A,B,C,X,Y = map(int,input().split(" "))
Z = max(X,Y)
o = Z * 2 * C
for z in range(Z+1):
    x = max(X-z,0)
    y = max(Y-z,0)
    o = min(x*A+y*B+z*2*C,o)

print(o)

Submission status: Accepted

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

Submission status: Accepted

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

#buy set of A,B
nab = min(x, y)
ans += nab*c2
x -= nab
y -= nab


#buy remainder
ans += x * a
ans += y * b
print(ans)

Submission status: Accepted

Solution code:
A, B, C, X, Y = map(int, input().split())
AB = min(C*2,A+B)
A = min(A, C*2)
B = min(B, C*2)
ret = 0
while X + Y > 0:
	if X > 0 and Y > 0:
		ret += AB
		X -= 1
		Y -= 1
	elif X > 0:
		ret += A
		X -= 1
	elif Y > 0:
		ret += B
		Y -= 1
print(ret)

Submission status: Accepted

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

Submission status: Accepted

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

min_price = 2 * 5000 * 100000
for nab in range(0, 2 * max(x, y) + 1, 2):
    na = max(0, x - nab // 2)
    nb = max(0, y - nab // 2)
    min_price = min(min_price, nab * c + na * a + nb * b)

print(min_price)

Submission status: Accepted

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

tmp1,tmp2,tmp3 = 0,0,0

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

tmp2 = a*x+b*y

print(min(tmp1,tmp2,tmp3))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b,c,x,y=map(int,input().split())
X=x
Y=y
MIN=10**9
while True:
    sum_=a*x+b*y+2*c*(max(X-x,Y-y))
    MIN=min(MIN,sum_)
    if x==0 and y==0:
        break
    if x>0:
        x-=1
    else:
        x=0
    if y>0:
        y-=1
    else:
        y=0
print(MIN)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a, b, c, x, y = map(int, input().split())
d = []
for num_c in range(max(x, y)+1):
    money = num_c * 2 * c + max(x-num_c, 0) * a + max(y-num_c, 0) * b
    d.append(money)
print(min(d))

Submission status: Accepted

Solution code:
A,B,C,X,Y = [int(x) for x in input().split()]
ans = 10**15
ans = min(ans,X*A+Y*B)
if(X<Y):
    ans = min(ans,2*X*C+(Y-X)*B)
else:
    ans = min(ans,2*Y*C+(X-Y)*A)
ans = min(ans,2*max(X,Y)*C)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
	A, B, C, X, Y = map(int, input().split())
	max_num_c = max(X, Y)*2

	ans = A*X+B*Y
	for num_c in range(0, max_num_c+1, 2):
		num_a = max(0, X-num_c//2)
		num_b = max(0, Y-num_c//2)
		current = A*num_a+B*num_b+C*num_c
		ans = min(ans, current)

	print(ans)

if __name__ == '__main__':
    main()

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

Submission status: Accepted

Solution code:
def pricing(A, B, C, tmp):
    A_price = tmp * A
    B_price = tmp * B
    AnB_price = A_price + B_price
    AB_price = tmp * 2 * C
    price = AnB_price if AnB_price < AB_price else AB_price
    return price


A, B, C, X, Y = map(int, input().split())
tmp = min(X, Y)
price = pricing(A, B, C, tmp)

tmp = max(X, Y) - tmp
if X > Y:
    price += pricing(A, 0, C, tmp)
else:
    price += pricing(0, B, C, tmp)

print(price)

Submission status: Accepted

Solution code:
def pricing(A, B, C, tmp):
    A_price = tmp * A
    B_price = tmp * B
    AnB_price = A_price + B_price
    AB_price = tmp * 2 * C
    price = AnB_price if AnB_price < AB_price else AB_price
    return price


A, B, C, X, Y = map(int, input().split())
ans = 0
tmp = min(X, Y)
price = pricing(A, B, C, tmp)

if X > Y:
    tmp = max(X, Y) - tmp
    price += pricing(A, 0, C, tmp)
else:
    tmp = max(X, Y) - tmp
    price += pricing(0, B, C, tmp)

print(price)

Submission status: Accepted

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

#A,Bだけで買う場合
bill_ab = a * x + b * y

#少ないほうはCで賄う場合
if x <= y:
  bill_abc = x * 2*c + (y - x) * b
else:
  bill_abc = y * 2*c + (x - y) * a

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


print(min(bill_ab, bill_abc, bill_c))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A, B, C, X, Y = map(int, input().split())
K = max(X, Y)
sum = 10 ** 12

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

print(sum)

Submission status: Accepted

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

while X > 0 or Y > 0:
    if X > 0 and Y > 0:
        if A + B > 2 * C:
            sum += 2 * C
        else:
            sum += A + B
        X -= 1
        Y -= 1
    else:
        if X > 0:
            if A > 2 * C:
                sum += 2 * C
            else:
                sum += A
            X -= 1
        else:
            if B > 2 * C:
                sum += 2 * C
            else:
                sum += B
            Y -= 1

print(sum)

Submission status: Accepted

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

while X > 0 or Y > 0:
    if X > 0 and Y > 0:
        if A + B > 2 * C:
            sum += 2 * C
            X -= 1
            Y -= 1
        else:
            sum += A + B
            X -= 1
            Y -= 1
    else:
        if X > 0:
            if A > 2 * C:
                sum += 2 * C
                X -= 1
                Y -= 1
            else:
                sum += A
                X -= 1
        else:
            if B > 2 * C:
                sum += 2 * C
                X -= 1
                Y -= 1
            else:
                sum += B
                Y -= 1

print(sum)

Submission status: Accepted

Solution code:
# coding: utf-8
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-Y)) if X>Y else B*(Y-X))))

Submission status: Accepted

Solution code:
# coding: utf-8

A, B, C, X, Y = map(int, input().split())
pt1 =(A*X)+(B*Y)
pt2 = 2*C*max(X,Y)
pt3 = 2*C*min(X,Y)+((A*(X-Y)) if X>Y else B*(Y-X))

print(min(pt1,pt2,pt3))

Submission status: Accepted

Solution code:
# coding: utf-8

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

ans = 0

pt1 =(A*X)+(B*Y)
pt2 = 2*C*max(X,Y)
pt3 = 2*C*min(X,Y)+((A*(X-Y)) if X>Y else B*(Y-X))

print(min(pt1,pt2,pt3))

Submission status: Accepted

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

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

print(answer)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(A: int, B: int, C: int, X: int, Y: int):
    ans = 0
    if 2*C < A+B:     # C買うフェイズ
        ge = min(X, Y)
        ans += C*2*ge
        X -= ge
        Y -= ge

    if X > 0:                   # コスパよくAを集める
        if 2*C < A:
            ans += C*2*X
        else:
            ans += A*X
    if Y > 0:
        if 2*C < B:
            ans += C*2*Y
        else:
            ans += B*Y
    print(ans)

    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())

ans = 10**9
for i in range(max(X, Y)+1):
    price = 2*C*i
    p_A, p_B = X, Y
    p_A -= i
    p_B -= i
    if p_A > 0:
        price += p_A*A
    if p_B > 0:
        price += p_B*B
    ans = min(ans, price)

print(ans)

Submission status: Accepted

Solution code:
a,b,c,x,y=map(int,input().split())
ans=10000000000
for i in range(0,(max(x,y)+1)):
  k=c*2*i+a*max(0,(x-i))+max(0,b*(y-i))
  ans=min(ans,k)
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:
    ans = 0
    num = 0
    if X < Y:
        ans += 2 * C * X
        num = Y - X
        if B > 2*C:
            ans += 2 * C * num
        else:
            ans += B * num
    else:
        ans += 2 * C * Y
        num = X - Y
        if A > 2*C:
            ans += 2 * C * num
        else:
            ans += A * num
    print(ans)

Submission status: Accepted

Solution code:
def f():
    if (A+B) <= C*2:
        return A*X+B*Y
    elif X==Y:
        return X*C*2
    else:
        if X > Y:
            if A > C*2:
                return (C*2)*(X-Y)+Y*C*2
            return A*(X-Y)+Y*C*2
        else:#Yの方が多い
            if B > C*2:
                return (C*2)*(Y-X)+X*C*2
            return B*(Y-X)+X*C*2
A,B,C,X,Y = map(int,input().split())
print(f())

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*C*Y+A*(X-Y))
		else:
			print(2*C*X)
	else:
		if B <= 2*C:
			print(2*C*X+B*(Y-X))
		else:
			print(2*C*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:
  ans = min(x, y) * 2 * c
  if x <= y:
    ans += min((y-x)*b, (y-x)*2*c)
  else:
    ans += min((x-y)*a, (x-y)*2*c)
  print(ans)

Submission status: Accepted

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

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

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(100005):
    tmp = i * 2 * c
    tmp += max(0, x-i) * a
    tmp += max(0, y-i) * b
    ans = min(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(200005):
    tmp = i * 2 * c
    tmp += max(0, x-i) * a
    tmp += max(0, y-i) * b
    ans = min(ans, tmp)

print(ans)

Submission status: Accepted

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

ans = 0
# ab is higher than a+b, dont buy ab pizza
if a + b <= 2*c:
    ans = a*x + b*y
# a and b pizza is higher than ab*2, dont buy a, b pizza
elif a >= c*2 and b >= c*2:
    ans = c * max(x,y) * 2
elif a < c*2 and b >= c*2:
    ans = c*y*2 + max(0, x-y) * a
elif a >= c*2 and b < c*2:
    ans = c*x*2 + max(0, y-x) * b
else:
    ans = min(x, y) * 2 * c + a * (x-min(x,y)) + b * (y-min(x, y))

print(ans)

Submission status: Accepted

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

print(ans)

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

print(ans)

Submission status: Accepted

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

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

print(min_cost)