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

l = list()
for i in range(max(X, Y)+1):
    cst = 2*C*i + max(0, X-i)*A + max(0, Y-i)*B
    l.append(cst)

print(min(l))

Submission status: Accepted

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

Submission status: Accepted

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

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

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*c*2+a*max(x-i,0)+b*max(y-i,0)
    ans=min(ans,tmp)
print(ans)

Submission status: Accepted

Solution code:
#print#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))
#%%code
from collections import Counter
def resolve():
    A,B,C,X,Y=pin()
    ans=A*X+B*Y
    if X>Y:
        ans=min(ans,A*(X-Y)+2*C*Y)
        ans=min(ans,C*2*X)
    else:
        ans=min(ans,B*(Y-X)+2*C*X)
        ans=min(ans,C*2*Y)
    print(ans)
#%%submit!
resolve()

Submission status: Accepted

Solution code:
a, b, c, x , y = map(int, input().split())
ans = []
# そのまま
ans.append(a*x + b*y)
# 全部1/2
ans.append(max(x, y)*c*2)
# 1/2 あまりをそのまま
p = a if x > y else b
ans.append(min(x, y)*c*2 + (abs(x - y) * p))
print(min(ans))

Submission status: Accepted

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

for i in range(1, max(X,Y)+1):
    if X >= i:
        A_num = X-i
    else:
        A_num = 0
    if Y >= i:
        B_num = Y-i
    else:
        B_num = 0
    # print(i, C*i+A*A_num+B*B_num, A_num, B_num)
    ans = min(ans, C*i+A*A_num+B*B_num)

print(ans)

Submission status: Accepted

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

ans1 = A * X + B * Y

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

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

print(min(ans1, ans2, ans3))

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
a,b,c,x,y = map(int, input().split())
min_price = 10**100
for n_ab in range(0, 2*max(x, y) + 1, 2):
    price = c * n_ab
    rest_x = x - n_ab//2
    if rest_x <= 0:
        rest_x = 0
    rest_y = y - n_ab//2
    if rest_y <= 0:
        rest_y = 0 
    price += rest_x * a + rest_y * b
    min_price = min(min_price, price)

print(min_price)

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import bisect
import math
import sys
from collections import Counter, defaultdict, deque
from copy import copy, deepcopy
from heapq import heapify, heappop, heappush
from itertools import combinations, permutations
from queue import Queue

read = sys.stdin.read
readline = sys.stdin.readline 
readlines = sys.stdin.readlines 

inf = float("inf")


def main():
    A, B, C, X, Y = map(int, input().split())
    if A + B > 2 * C:
        if X > Y:
            ret = 2 * C * Y
            if A > 2 * C:
                ret += 2 * C * (X - Y)
            else:
                ret += A * (X - Y)
        else:
            ret = 2 * C * X
            if B > 2 * C:
                ret += 2 * C * (Y - X)
            else:
                ret += B * (Y - X)
    else:
        ret = A * X + B * Y
    print(ret)
        
      
if __name__=='__main__':
    main()

Submission status: Accepted

Solution code:
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]

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

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

Submission status: Accepted

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

Submission status: Accepted

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

AB = A + B

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

print(ans_cost)

Submission status: Accepted

Solution code:
def main():
    from sys import stdin
    a,b,c,x,y = map(int,stdin.readline().rstrip().split())

    p1 = a*x+b*y
    p2 = max(x,y)*c*2
    p3 = min(x,y)*c*2+max(x-y,0)*a+max(y-x,0)*b
    print(min(p1,p2,p3))
main()

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

Submission status: Accepted

Solution code:
A,B,C,X,Y = map(int, input().split())
ans = 0
if A+B <= 2*C:
    ans = A*X + B*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 = a*x+b*y
if x==y:
  conly = c*x*2
  print(min(ab,conly))
elif x>y:
  conly = c*x*2
  ac = c*y*2+(x-y)*a
  print(min(ab,conly,ac))
else:
  conly = c*y*2
  bc = c*x*2+(y-x)*b
  print(min(ab,conly,bc))

Submission status: Accepted

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

p1 = a*x + b*y
p2 = c * 2 * max(x, y)
if x >= y:
  p3 = c * 2 * y + a*(x-y)
else:
  p3 = c * 2 * x + b*(y-x) 

print(min(p1,p2,p3))

Submission status: Accepted

Solution code:
def main():
    a, b, c, x, y = map(int, input().split())
    res = 10**100
    for i in range(10**5+1):
        pizza_a = max(0, x-i) * a
        pizza_b = max(0, y-i) * b
        pizza_c = 2 * c * i
        cost = pizza_c + pizza_a + pizza_b
        res = min(res, cost)
    print(res)

if __name__ == "__main__":
    main()

Submission status: Accepted

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

INF = float('inf')
min_cost = INF

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

print(min_cost)

Submission status: Accepted

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

def resolve():
    import math
    a,b,c,x,y=map(int, input().split())
    # ABピザを奇数枚買っても1枚無駄になるから、ABピザは2枚を1枚だと考える
    # cの値段を2倍にして枚数を半分に
    cmax=max(x,y) # ABピザの最大枚数(2枚を1枚と考えたとき)
    c=2*c
    l=[]
    for i in range(cmax+1):
        amai = max(x - i,0)
        bmai = max(y - i,0)
        l.append(amai*a+bmai*b+i*c)
    print(min(l))
resolve()

Submission status: Accepted

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

def resolve():
    import math
    a,b,c,x,y=map(int, input().split())
    cmax=max(x,y)*2
    l=[]
    for i in range(cmax+1):
        amai = max(math.ceil(x - 0.5 * i),0)
        bmai = max(math.ceil(y - 0.5 * i),0)
        l.append(amai*a+bmai*b+i*c)
    print(min(l))
resolve()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

price = 0

if A+B > 2*C:
    if X >= Y:
        price += 2*C*Y
        remain = X-Y
        if A >= 2*C:
            price += 2*C*remain
        else:
            price += A*remain
    else:
        price += 2*C*X
        remain = Y-X
        if B >= 2*C:
            price += 2*C*remain
        else:
            price += B*remain
else:
    if X >= Y:
        price += (A+B)*Y
        remain = X-Y
        if A >= 2*C:
            price += 2*C*remain
        else:
            price += A*remain
    else:
        price += (A+B)*X
        remain = Y-X
        if B >= 2*C:
            price += 2*C*remain
        else:
            price += B*remain

print(price)

Submission status: Accepted

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

def resolve():
    import math
    a,b,c,x,y=map(int, input().split())
    cmax=max(x,y)*2
    l=[]
    for i in range(cmax+1):
        amai = math.ceil(x - 0.5 * i)
        bmai = math.ceil(y - 0.5 * i)
        if 0.5*i>=x and 0.5*i>=y:
            amai=0
            bmai=0
        elif 0.5*i>=x:
            amai=0
        elif 0.5*i>=y:
            bmai=0
        l.append(amai*a+bmai*b+i*c)
    print(min(l))
resolve()

Submission status: Accepted

Solution code:
import sys
readline = sys.stdin.readline
intin = map( int, readline().rstrip().split() )

a , b ,c , x , y  = intin

times = max(x,y)

total = 0
for t in range(times):
    if x > 0 and y > 0 :
        if a + b >= 2 * c :
            total += 2 * c
            x -= 1
            y -= 1
            continue
        else:
            total += a+b
            x -= 1 
            y -= 1
            continue
    elif x > 0 and y <= 0 :
        if a > 2 * c :
            total += 2 * c
            x -= 1
            continue
        else:
            total += a
            x -= 1
            continue
    elif y > 0 and x <= 0 :
        if b > 2 * c :
            total += 2 * c
            y -= 1
            continue
        else:
            total += b
            y -= 1
            continue
    else:
        break

print(total)

Submission status: Accepted

Solution code:
import sys
import heapq
import re
from itertools import permutations
from bisect import bisect_left, bisect_right
from collections import Counter, deque
from fractions import gcd
from math import factorial, sqrt, ceil
from functools import lru_cache, reduce
INF = 1 << 60
MOD = 1000000007
sys.setrecursionlimit(10 ** 7)

# UnionFind
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

def is_prime(n):
    if n == 1:
        return False
    for i in range(2,int(n**0.5)+1):
        if n % i == 0:
            return False
    return True


# ワーシャルフロイド (任意の2頂点の対に対して最短経路を求める)
# 計算量n^3 (nは頂点の数)
def warshall_floyd(d, n):
    #d[i][j]: iからjへの最短距離
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d


# ダイクストラ
def dijkstra_heap(s, edge, n):
    #始点sから各頂点への最短距離
    d = [10**20] * n
    used = [True] * n #True:未確定
    d[s] = 0
    used[s] = False
    edgelist = []
    for a,b in edge[s]:
        heapq.heappush(edgelist,a*(10**6)+b)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        #まだ使われてない頂点の中から最小の距離のものを探す
        if not used[minedge%(10**6)]:
            continue
        v = minedge%(10**6)
        d[v] = minedge//(10**6)
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,(e[0]+d[v])*(10**6)+e[1])
    return d

# 素因数分解
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

# 2数の最小公倍数
def lcm(x, y):
    return (x * y) // gcd(x, y)

# リストの要素の最小公倍数
def lcm_list(numbers):
    return reduce(lcm, numbers, 1)

# リストの要素の最大公約数
def gcd_list(numbers):
    return reduce(gcd, numbers)

# 素数判定



# limit以下の素数を列挙
def eratosthenes(limit):
    A = [i for i in range(2, limit+1)]
    P = []

    while True:
        prime = min(A)
        
        if prime > sqrt(limit):
            break
            
        P.append(prime)
            
        i = 0
        while i < len(A):
            if A[i] % prime == 0:
                A.pop(i)
                continue
            i += 1
            
    for a in A:
        P.append(a)
            
    return P

# 同じものを含む順列
def permutation_with_duplicates(L):

    if L == []:
        return [[]]

    else:
        ret = []

        # set（集合）型で重複を削除、ソート
        S = sorted(set(L))

        for i in S:

            data = L[:]
            data.remove(i)

            for j in permutation_with_duplicates(data):
                ret.append([i] + j)

        return ret


# ここから書き始める
a, b, c, x, y = map(int, input().split())
n = 2 * max(x, y)
ans = INF
for z in range(n + 1):
    # abピザにかかるコスト
    costc = c * z

    # 必要なaピザの枚数
    cnta = max(0, x - z // 2)

    # 必要なbピザの枚数
    cntb = max(0, y - z // 2)

    # コストの合計
    cost = costc + a * cnta + b * cntb

    ans = min(ans, cost)
print(ans)

Submission status: Accepted

Solution code:
a,b,ab,ax,bx = map(int,input().split())
#a,b,ab,ax,bx = (1500, 2000, 1600, 3, 2)

import math
import sys

abmax = max(ax,bx)*2
candi = list()

for nab in range(abmax,-1,-1):
  na = max(math.ceil(ax - nab * 0.5),0)
  nb = max(math.ceil(bx - nab * 0.5),0)
  candi.append((na,nb,nab))

mincost = candi[0][0]*a + candi[0][1]*b + candi[0][2]*ab

for i in candi:
  cost = i[0]*a + i[1]*b + i[2]*ab
  if(cost < mincost):
    mincost = cost

print(mincost)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
def S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())

A,B,C,X,Y = LI()

only = A*X+B*Y
only_mix = C*max(X,Y)*2
comp = 0
if X > Y:
    comp = C*Y*2+A*(X-Y)
elif X < Y:
    comp = C*X*2+B*(Y-X)
else:
    comp = C*Y*2

print(min(only,only_mix,comp))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

cost = a*x+b*y

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

print(cost)

Submission status: Accepted

Solution code:
A, B, C, X, Y = map(int, input().split())
c_max = max(X, Y) * 2
ans = float('inf')
for c in range(0, c_max+1, 2):
    a = X - c // 2
    b = Y - c // 2
    ans = min(max(a, 0)*A + max(b, 0)*B + c*C, ans)

print(ans)

Submission status: Accepted

Solution code:
import sys
a,b,c,x,y = map(int,input().split())
ans = a*x + b*y
for i in range(max(x,y)+1):
    if (x-i >=0) and (y-i >=0):
        id = a*(x-i) + b*(y-i) + 2*c*i
        if id <= ans:
            ans = id
        else:
            print(ans)
            sys.exit()
    elif (x-i <0) and (y-i>=0):
        id = b*(y-i) + 2*c*i
        if id <= ans:
            ans = id
        else:
            print(ans)
            sys.exit()
    elif (x-i >=0) and (y-i<0):
        id = a*(x-i) + 2*c*i
        if id <= ans:
            ans = id
        else:
            print(ans)
            sys.exit()
print(ans)

Submission status: Accepted

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

AB_optimal = min(A+B, C*2)
A_optimal = min(A,C*2)
B_optimal = min(B,C*2)

XY_diff = abs(X-Y)

ans = 0
if X>=Y:
  ans += (X-XY_diff) * AB_optimal
  ans += XY_diff * A_optimal
else:
  ans += (Y-XY_diff) * AB_optimal
  ans += XY_diff * B_optimal

print(ans)

Submission status: Accepted

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


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

if Y < X and C * 2 < A:
    ans = ans + (X - Y) * C * 2
elif Y < X:
    ans = ans + (X - Y) * A
elif X < Y and C * 2 < B:
    ans = ans + (Y - X) * C * 2
elif X < Y:
    ans = ans + (Y - X) * B
else:
    pass
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

costs = 0

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

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

print(ans)
"""

price1 = A * X + B * Y
price2 = C * 2 * X + B * max(Y - X, 0)
price3 = A * max(X - Y, 0) + C * 2 * Y
print(min(price1, price2, price3))

Submission status: Accepted

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

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

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

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

print(ans)

Submission status: Accepted

Solution code:
a,b,c,x,y=map(int, input().split( ))
#超過してよい
#x,y<=10000
ans=10**15

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

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

total = 0

#
if a + b >= 2*c:    # ABを買う場合
    if (max(x, y) == x and 2*c < a) or (max(x, y) == y and 2*c < b):    # ABのみを買う場合
        total = max(x, y) * 2*c
    else:
        # 足りない方を買い足す場合
        if min(x, y) == x:
            total = x * 2 * c + (y - x) * b
        else:
            total = y * 2 * c + (x - y) * a
else:               # ABを買わない場合
    total = a*x + b*y

print(total)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b,c,x,y = map(int,input().split())
if x >y:
    mini = [b,y]
    maxi = [a,x]
else:
    maxi = [b,y]
    mini = [a,x]

cost = 0
if a+b > 2*c:
    cost += c*mini[1]*2
    dif = maxi[1]-mini[1]
    if dif*maxi[0] > c*2*dif:
        cost += c*2*dif
    else:
        cost += dif * maxi[0]
else :
    cost += mini[0]*mini[1] + maxi[0]*maxi[1]

print(cost)

Submission status: Accepted

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

Submission status: Accepted

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

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

result = 5000*5000*200000
ab = 0
while(x >= 0):
    tmp = x * a + y * b + ab*c
    if(result > tmp):
        result = tmp
    x -= 1
    if(y > 0):
        y -= 1
    ab += 2

print(result)

Submission status: Accepted

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

Submission status: Accepted

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

min = X if X < Y else Y
max = X if X > Y else Y
sub = X - Y

if A+B > 2*C:
    ch = 2*C
else:
    ch = A+B

m = ch * min

if sub > 0:
    m += sub * A
else:
    m += sub * B * (-1)
    
m_ = ch * max

if m_ > m:
    print(m)
else:
    print(m_)

Submission status: Accepted

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

cost = 0

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

result = a * x + b * y

mx = max([x, y])

for i in range(1, mx + 1):
    tmp = a * max([(x - i), 0]) + b * max([(y - i), 0]) + c * 2 * i

    if result > tmp:
        result = tmp

print(result)

Submission status: Accepted

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

Submission status: Accepted

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


def readstr():
    return input().strip()


def readint():
    return int(input())


def readnums():
    return map(int, input().split())


def readstrs():
    return input().split()


A, B, C, X, Y = readnums()

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

print(ans)

Submission status: Accepted

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

answer = 10**18
for c in range(10**5+1):
  a = X-c
  b = Y-c
  cost = C*c*2
  cost += max(a,0)*A
  cost += max(b,0)*B
  answer = min(answer,cost)
print(answer)

Submission status: Accepted

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

answer = 10**18
for c in range(10**5+1):
  a = X-c
  b = Y-c
  cost = C*c*2
  cost += max(a,0)*A
  cost += max(b,0)*B
  if answer > cost:
    answer = cost
print(answer)

Submission status: Accepted

Solution code:
a,b,c,x,y = map(int,input().split())
A_B = a*x+b*y
AB = 2*c*max(x,y)
A_AB = 10**11
AB_B = 10**11
if x-y > 0:
  A_AB = a*(x-y)+2*c*y
if y-x > 0:
  AB_B = 2*c*x+b*(y-x)

ans = min(A_B,A_AB,AB_B,AB)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

  min_cost = 2 * (10 ** 5) * max(A, B, C)

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

  print(min_cost)

if __name__ == "__main__":
    main()

Submission status: Accepted

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

  min_cost = 2 * (10 ** 5) * max(A, B, C)

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

  print(min_cost)

if __name__ == "__main__":
    main()

Submission status: Accepted

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

z = max(X,Y)*2

act_list = []
for i in range(0,z+1,2):
    x = int(X - i*0.5)
    y = int(Y - i*0.5)
    
    if x <= 0:
        x = 0
    if y <= 0:
        y = 0
    act = x * A + y * B + i * C
    act_list.append(act)

print(min(act_list))

Submission status: Accepted

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