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 = tuple(map(int, input().split(" ")))

half = 0
if C * 2 <= A:
    half = X * 2
if C * 2 <= B:
    half = max(Y * 2, half)
if C <= (A + B) // 2:
    half = max(half, min(X, Y) * 2)

cost = half * C
X -= half // 2
Y -= half // 2

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

print(cost)

Submission status: Accepted

Solution code:
import sys
stdin = sys.stdin

mod = 10**9 + 7

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))

A, B, C, X, Y = na()
ans = 10**10
for ab in range((10**5+1)*2):
    cost = ab * C
    cost += max(0, X - ab//2) * A
    cost += max(0, Y - ab//2) * B
    ans = min(ans, cost)
print(ans)

Submission status: Accepted

Solution code:
a,b,c,x,y = map(int,input().split())
res = 9999999999999
for i in range(0, 200002, 2):
    na = x - i//2
    nb = y - i//2
    na = 0 if na < 0 else na
    nb = 0 if nb < 0 else nb
    res = min(res, c * i + a*na + b*nb)
print(res)

Submission status: Accepted

Solution code:

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

if a + b < c * 2:
    p = a * x + b * y
else:
    if x > y:
        x -= y
        z = y * 2
        y = 0
        if a > c * 2:
            z += x * 2
            x = 0

    else:
        y -= x
        z = x * 2
        x = 0
        if b > c * 2:
            z += y * 2
            y = 0

print(x * a + y * b + z * c)

Submission status: Accepted

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

if (2*c<a and 2*c<b):
    #cだけを買う
    ans = max(x,y)*2*c

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

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

Submission status: Accepted

Solution code:
import sys, math
def input():
    return sys.stdin.readline()[:-1]
from itertools import permutations, combinations
from collections import defaultdict, Counter
from math import factorial
from bisect import bisect_left # bisect_left(list, value)
#from fractions import gcd

sys.setrecursionlimit(10**7)
A, B, C, X, Y = map(int, input().split())

val1 = A*X + B*Y
minXY = min(X, Y)
val2 = C*2*minXY + A*(X-minXY) + B*(Y-minXY)
maxXY = max(X, Y)
val3 = C*2*maxXY

print(min(val1, val2, val3))

Submission status: Accepted

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

Submission status: Accepted

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

## ABピザを買うパターン、買わないパターンの2パターンを計算して、小さい方を出力する

## 1.ABピザを買わないパターン
ans = A*X + B*Y

## 2.ABピザを買うバターン
## 2-1.余計なピザは買わない
if X > Y:
  _ = Y*C*2 + abs(X-Y)*A
else:
  _ = X*C*2 + abs(X-Y)*B
ans = min(ans,_)  

## 2-2.余計なピザを買う
_ = max(X,Y)*C*2
ans = min(ans,_)

## 3.answer
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

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

ans=10**100

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


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

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

Submission status: Accepted

Solution code:
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time


def I(): return int(input())


def S(): return input()


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


def MS(): return map(str, input().split())


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


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YNL = {False: 'No', True: 'Yes'}
YNU = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']

show_flg = False
# show_flg = True


def main():
    A, B, C, X, Y = MI()

    a = A * X + B * Y
    b = max(C * X * 2, C * Y * 2)
    c = C * X * 2 + B * max(Y - X, 0)
    d = C * Y * 2 + A * max(X - Y, 0)
    print(min(a, b, c, d))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

a,b,c,x0,y0=mii()

tmp=10**100

x,y=x0,y0
chk=min(x//2,y//2)
ans = c*2 *(chk)*2
x-=chk*2
y-=chk*2 
if x>=1:
    ans+=min(a*x,x*c*2)
if y>=1:
    ans+=min(y*b,y*c*2)
tmp=min(ans,tmp)

x,y=x0,y0
chk=max(x//2,y//2)
ans = c*2 *(chk)*2
x-=chk*2
y-=chk*2 
if x>=1:
    ans+=min(a*x,x*c*2)
if y>=1:
    ans+=min(y*b,y*c*2)
tmp=min(ans,tmp)

x,y=x0,y0
ans =a*x+b*y
tmp=min(ans,tmp)

ans=a*x + c*2*y
tmp=min(ans,tmp)

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

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

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


print(tmp)

Submission status: Accepted

Solution code:
import sys

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

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

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

print(ans)

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
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*max(0,X-Y)+B*max(0,Y-X)))

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
def ABC106_B():
    def make_divisors(n):
        divisors = []
        for i in range(1, int(n ** 0.5) + 1):
            if n % i == 0:
                divisors.append(i)
                if i != n // i:
                    divisors.append(n // i)
        # divisors.sort()
        return divisors
    N = I()
    ans = 0
    for i in range((N+1)//2):
        cur = i*2+1
        if len(make_divisors(cur))==8:
            ans += 1
    print(ans)
    return

def ABC122_B():
    S = SI()
    ans = 0
    cur = 0
    d = {"A","C","G","T"}
    for s in S:
        if s in d:
            cur += 1
        else:
            ans = max(ans,cur)
            cur = 0
    ans = max(ans,cur)
    print(ans)
    return

def paken2019_C():
    N, M = LI()
    A = [LI()for _ in range(N)]
    T = [i for i in range(M)]
    ans = 0
    for t1,t2 in itertools.permutations(T,2):
        cur = 0
        for i in range(N):
            cur += max(A[i][t1],A[i][t2])
        ans = max(ans,cur)
    print(ans)
    return

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

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

import sys,copy,bisect,itertools,heapq,math,random
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

if __name__ == '__main__':
    ABC95_C()

"""

"""

Submission status: Accepted

Solution code:
a, b, c, x, y = map(int, input().split())
mi = 10**10
for i in range(10**6):
    cost = c*2*i + a*max((x-i), 0) + b*max((y-i), 0)
    if cost < mi:
        mi = cost

print(mi)

Submission status: Accepted

Solution code:
A,B,C,x,y = map(int,input().split())
a = 0
b = 0
c = 0
if C*2 >= A + B:
    print (A*x+B*y)
    exit(0)

if C * 2 <= A and C * 2 <= B:
    print (max(x,y) * 2 * C)
    exit(0)

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

Submission status: Accepted

Solution code:
A,B,C,X,Y=map(int,input().split())
#print(A,B,C,X,Y)
M=max(X,Y)*2
ans=float('inf')
for i in range(M+1):
  x=max(0,X-i//2)
  y=max(0,Y-i//2)
  #x=max(0,X-(-(-i//2)))
  #y=max(0,Y-(-(-i//2)))
  tmp=A*x+B*y+C*i
  if ans>tmp:
    ans=tmp
print(ans)

Submission status: Accepted

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

if c*2 < a + b:
    #ABピザに変更するインセンティブが発生している
    if x > y:
        ab_needed = y
        if a < c*2:
            answer += (x-y)*a
        else:
            answer += (x-y)*2*c
    else:
        ab_needed = x
        if b < c*2:
            answer += (y-x)*b
        else:
            answer += (y-x)*2*c
    answer += ab_needed*2*c
else:
    answer += a*x + b*y

print(answer)

Submission status: Accepted

Solution code:
import sys
import math
from collections import deque
import copy
import bisect

MOD = 10 ** 9 + 7
INF = 10 ** 18 + 7
input = lambda: sys.stdin.readline().strip()

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

ans = 0
while X > 0 or Y > 0:
    if X > 0 and Y > 0:
        if 2*C <=  A+B:
            X -= 1
            Y -= 1
            ans += 2*C
        else:
            X -= 1
            Y -= 1
            ans += A+B
    elif X > 0:
        if 2*C <= A:
            X -= 1
            ans += 2*C
        else:
            X-= 1
            ans += A
    else:
        if 2*C <= B:
            Y -= 1
            ans += 2*C
        else:
            Y -= 1
            ans += B
print(ans)

Submission status: Accepted

Solution code:
A, B, C, X, Y = map(int, input().split())
ans = float('inf')
for i in range(0, 10**5+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 = 5000*(10**5)*2
for i in range(max(x, y)+1):
    tmp_ans = i*2*c
    if x > i:
        tmp_ans += (x-i)*a
    if y > i:
        tmp_ans += (y-i)*b
    ans = min(ans, tmp_ans)

print(ans)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
inf = (5000 * 10 ** 5) * 3

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

ret = inf
for cnt_ab in range(max(x, y) * 2 + 1):
    d = cnt_ab // 2

    cnt_a = max(0, x - d)
    cnt_b = max(0, y - d)

    t = cnt_ab * c + cnt_a * a + cnt_b * b
    ret = min(ret, t)
print(ret)

Submission status: Accepted

Solution code:
a, b, c, x, y = map(int, input().split())
price = a * x + b * y
for i in range(min(x,y)):
    if a + b > 2 * c:
        price = price - (a + b) + 2 * c
    else:
        break

for i in range(max(x, y) - min(x, y)):
    if (x > y):
        if (a > 2 * c):
            price = price - a + 2 * c
        else:
            break
    else:
        if (b > 2 * c):
            price = price - b + 2 * c 
print(price)

Submission status: Accepted

Solution code:
a,b,c,x,y = map(int,input().split())
cur = a*x+b*y
z = 0
while True:
  x,y,z = x-1,y-1,z+2
  if a*max(0,x)+b*max(0,y)+c*z <= cur:
    cur = a*max(0,x)+b*max(0,y)+c*z
  else:
    print(cur)
    exit()

Submission status: Accepted

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

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

q = a*x + b*y
r = 2*c * max(x, y)

print(min(p, q, r))

Submission status: Accepted

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

ans = float('inf')
for i in range(0,max(x,y)*2 + 1,2):
  price = i*c+ max(x-i//2,0)*a + max(y-i//2,0)*b
  ans = min(price,ans)
print(ans)

Submission status: Accepted

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

ans = float('inf')
for k in range(2*max(x, y)+1):
    cost = c * k
    need_x = max(0, x - k // 2)
    need_y = max(0, y - k // 2)
    cost += a * need_x + b * need_y
    ans = min(ans, cost)
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())

def best_pizza_cost(ln, hn):
    if ln == X: lp = A
    else: lp = B

    if hn == Y: hp = B
    else: hp = A

    fnp = lp * ln + hp * ln
    fhp = C * ln * 2

    left = hn-ln
    snp = hp * left
    shp = C * left * 2
    #print(fnp, fhp, snp, shp)
    return min(fnp, fhp) + min(snp, shp)

print(best_pizza_cost(min(X, Y), max(X, Y)))

Submission status: Accepted

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

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
import re
import queue


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 sign(n):
        if n == 0:
            return 0
        if n < 0:
            return -1
        return 1

    @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

    @staticmethod
    def divisor(n):
        i = 1
        table = []
        while i * i <= n:
            if n % i == 0:
                table.append(i)
                table.append(n // i)
            i += 1
        table = list(set(table))
        return table


class PriorityQueue:
    def __init__(self, l=[]):
        self.__q = l
        heapq.heapify(self.__q)
        return

    def push(self, n):
        heapq.heappush(self.__q, n)
        return

    def pop(self):
        return heapq.heappop(self.__q)

    def list(self):
        return self.__q

    def length(self):
        return len(self.__q)


sys.setrecursionlimit(1000000)
MOD = int(1e09) + 7
INF = int(1e30)


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


if __name__ == "__main__":
    main()

Submission status: Accepted

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

ans = 0

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

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

print(ans)

Submission status: Accepted

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

# i組みのabを買うことについて全探索
ans = float("inf")
for i in range(max(x, y)+1):
    price = i * 2 * c + max(x-i, 0) * a + max(y-i, 0) * b
    ans = min(ans, price)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import itertools

# import numpy as np

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

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

Submission status: Accepted

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

    ans = 1000000000

    tmp_x = x
    tmp_y = y

    for ab in range(max(x, y)+1):
        x -= ab
        y -= ab
        if x < 0:
            x = 0
        if y < 0:
            y = 0
        ans = min(ans, a * x + b * y + 2 * ab * c)
        x, y = tmp_x, tmp_y

    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
read_=sys.stdin.buffer.readline

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

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

print(min(ans1,ans2,ans3))

Submission status: Accepted

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

ans=10**10
for i in range(max(X,Y)+1):
    cnt=0
    cnt+=C*2*i
    x=X-i
    y=Y-i
    cnt+=max(0,x*A)
    cnt+=max(0,y*B)
    if ans>cnt:
        ans=cnt
print(ans)

Submission status: Accepted

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

ans = float('inf')
for i in range(0,2*10**5+1):
  cost = c * i
  cost += a * max(0, x - i//2)
  cost += b * max(0, y - i//2)
  ans = min(ans,cost)  
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:
    ans = min(X,Y) * 2 * C
    if X < Y:
        Z = Y - X
        ans += Z * min(B,2*C)
    else:
        Z = X - Y 
        ans += Z * min(A,2*C)
print(ans)

Submission status: Accepted

Solution code:
# https://atcoder.jp/contests/abc095/tasks/arc096_a
"""
別解(定数時間)
https://atcoder.jp/contests/abc095/submissions/10226556
"""

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

ans = float("inf")

# ABピザを2枚1組で考える -> ABセット
# i: ABセットの個数
for i in range(10**5 + 1):
    ans = min(ans, i*(2*C) + max(0, X-i)*A + max(0, Y-i)*B)

print(ans)

Submission status: Accepted

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

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

ans = 0

# MINXY個ずつ買う
MINXY = min(X,Y)
if A+B <= 2 * C:
    ans += (A+B) * MINXY
else:
    ans += (2 * C) * MINXY

X -= MINXY
Y -= MINXY

# 買い忘れを買う
if X == 0:
    if B <= 2 * C:
        ans += B * Y
    else:
        ans += (2 * C) * Y
else:
    if A <= 2 * C:
        ans += A * X
    else:
        ans += (2 * C) * X

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
"""
CでAやBが0.5枚できる分だけ買う意味はないので、必ず一枚作れるように買う
X,Yが 10**5までなので、Cで何枚作るか決めて、残りをA、B単品で埋めた時のコストの最小値を全探索
"""

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


ans = float("inf")
# iはCで何枚のA,Bを作るか
for i in range(max(X,Y)+1):
    # C買う分のコスト
    cost = 2*i*C
    # 残りのAのコスト
    if i < X:
        cost += (X-i)*A
    # 残りのBのコスト
    if i < Y:
        cost += (Y-i)*B
    ans = min(ans, cost)

print(ans)

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

Submission status: Accepted

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


if __name__ == '__main__':
    solve()

Submission status: Accepted

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

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

Submission status: Accepted

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


def solve(A: int, B: int, C: int, X: int, Y: int):
    result = 5000 * 10 ** 5 * 2 + 1
    for i in range(0, 10 ** 5 + 1):
        cost = i * 2 * C + max(0, X - i) * A + max(0, Y - i) * B

        result = min(result, cost)
    print(result)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    X = int(next(tokens))  # type: int
    Y = int(next(tokens))  # type: int
    solve(A, B, C, X, Y)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a, b, c, x, y = map(int, input().split())
ans = 0
cnt = 0
while x > cnt and y > cnt:
    ans += min(a+b, c*2)
    cnt += 1

if x > cnt:
    while x > cnt:
        ans += min(a, c*2)
        cnt += 1
else:
    while y > cnt:
        ans += min(b, c*2)
        cnt += 1
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A, B, C, X, Y = map(int, input().split())
min_num = min(X, Y)
max_num = min(X, Y)
min_price = min(A + B, C * 2)
max_price = min(A + B, C * 2)
answer = min_num * min_price
# print(answer)

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

print(answer)

Submission status: Accepted

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

if X > Y:
    max_pizzas = X
else :
    max_pizzas = Y
    
costs = []
for i in range(max_pizzas+1):
    A_left = X - i
    B_left = Y - i
    if A_left > 0:
        A_cost = A * A_left
    else :
        A_cost = 0

    if B_left > 0:
        B_cost = B * B_left
    else :
        B_cost = 0
    
    costs.append(A_cost + B_cost + (C * 2 * i))
    
print(min(costs))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

ans=10**10
Z=max(X,Y)

for i in range(2*Z+1):
    temp=i*C
    x=max(X-i//2,0)
    y=max(Y-i//2,0)
    temp+=A*x+B*y
    ans=min(ans,temp)
    
print(ans)