Problem:


Score : 300 points

Problem Statement

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

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

Constraints

1 ≤ A, B, C ≤ 5000

1 ≤ X, Y ≤ 10^5

All values in input are integers.

Input

Input is given from Standard Input in the following format:

A B C X Y

Output

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

Sample Input 1

1500 2000 1600 3 2

Sample Output 1

7900

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

Sample Input 2

1500 2000 1900 3 2

Sample Output 2

8500

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

Sample Input 3

1500 2000 500 90000 100000

Sample Output 3

100000000

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



Sample input:
1500 2000 1600 3 2


Sample output:
7900

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# /usr/bin/python3
# -*- coding: utf-8 -*-
from queue import Queue
from queue import LifoQueue as Stack
from math import sqrt, floor, ceil, log2, log10, pi
from fractions import gcd
from itertools import permutations, combinations
from operator import itemgetter
from functools import cmp_to_key


INF=1001001001
__MOD__=(10**9)+7
yn = 'YNeos'
judge = False
cnt = 0
ans = None


def lcm(a, b):
    return (a*b) // gcd(a,b)

def intinput():
    return int(input())

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

def lineinputs(func=intinput):
    datas = []
    while True:
        try:
            datas.append(func())
        except EOFError:
            break
    return datas

class ModInt():
    def __init__(self, x):
        self.__x = (x % __MOD__)
    def __add__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x + other.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x + other.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __radd__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((other.__x + self.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((other.__x + self.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")

    def __sub__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x - other.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x - other.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __rsub__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((other.__x - self.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((other.__x - self.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")

    def __mul__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x * other.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x * other.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __rmul__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((other.__x * self.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((other.__x * self.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")

    def __truediv__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x * other.__modinv())%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x * other.__modinv())%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __rtruediv__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((other.__x * self.__modinv())%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((other.__x * self.__modinv())%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")

    def __pow__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__(pow(self.__x, other.__x, __MOD__)))
        elif type(other) == ModInt:
            return self.__class__(pow(self.__x, other.__x, __MOD__))
        else:
            raise Exception("Not Int or Not ModInt")
    def __rpow__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__(pow(other.__x, self.__x, __MOD__)))
        elif type(other) == ModInt:
            return self.__class__(pow(other.__x, self.__x, __MOD__))
        else:
            raise Exception("Not Int or Not ModInt")

    def __modinv(self, m=__MOD__):
        a = self.__x
        if a == 0:
            raise ZeroDivisionError()
        if gcd(a, m) != 1:
            raise Exception("%sの逆数は求まりません。" % a)
        b, u, v = m, 1, 0
        while b != 0:
            t = a//b;
            a -= t*b
            a, b = b, a
            u -= t * v
            u, v = v, u
        u %= m
        if u < 0:
            u += m
        return u
    def __int__(self):
        return self.__x
    def __str__(self):
        return str(self.__x)



if __name__ == '__main__':
    A, B, C, X, Y = mulinputs()

    cost = A*X + B*Y
    for i in range(max(X,Y)+1):
        x = X - i if X > i else 0
        y = Y - i if Y > i else 0
        _cost = (A*x) + (B*y) + C*(2*i)
        cost = min(cost, _cost)

    # 出力
    print(cost)

Submission status: Accepted

Solution code:
import sys

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

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

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

print(cost)

Submission status: Accepted

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

ans = 0
if a > 2*c and x > 0: # aの価格がcの2倍以上ならx枚のピザをc円のピザで満たす
  ans += x*2*c
  y -= x
  x = 0
if b > 2*c and y > 0: # bの価格がcの2倍以上ならy枚のピザをc円のピザで満たす
  ans += y*2*c
  x -= y
  y = 0
if a+b >= 2*c and x > 0 and y > 0: # a+bの価格がcの2倍以上ならmin(x,y)枚のピザをc円のピザで満たす
  ans += 2*c*min(x,y)
  if x < y:
    y -= x
    x = 0
  elif y < x:
    x -= y
    y = 0
  else:
    x,y = 0,0
# 残りは普通に計算
if x > 0: ans += x*a
if y > 0: ans += y*b
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

if A+B >= 2*C:
    t = min(X, Y)
    r += 2 * t * C
    X -= t
    Y -= t
if 2*C <= A:
    r += X * 2 * C
    Y = max(Y-X, 0)
    X = 0
if 2*C <= B:
    r += Y * 2 * C
    X = max(X-Y, 0)
    Y = 0
r += A * X
r += B * Y
print(r)

Submission status: Accepted

Solution code:
a, b, c, x, y =map(int, input().split())
ab = 2*c
i = 0
cost = 0
minCost = 10**10
while i < 10**6:
    cost = i*ab
    cost += a *(max(0, (x-i)))
    cost += b *(max(0, (y-i)))
    if minCost >= cost:
        minCost = cost
    i += 1
print(minCost)

Submission status: Accepted

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

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

print(min(price))

Submission status: Accepted

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

price=0
if X>Y:    
  N_same=Y
  flag='A'
else:
  N_same=X
  flag='B'
  
if A+B >2*C:
  price+=2*C*N_same
else:
  price+=(A+B)*N_same

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

print(price)

Submission status: Accepted

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

Submission status: Accepted

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

ans=10**10
for i in range(0,2*max(X,Y)+1,2):#ABピザを買う枚数を２枚ずらしで全探索
    tmp = max(0,A*(X-0.5*i)) + max(0,B*(Y-0.5*i)) + C*i
    ans=min(ans,tmp)
print(int(ans))

Submission status: Accepted

Solution code:
A, B, C, X, Y = map(int, input().split())
ans0 = A * X + B * Y
# A
ans1 = A * X + 2 * C * Y
# B
ans2 = 2 * C * X + B * Y
# C
ans3 = 2 * C * max(X, Y)
# D
#
t = abs(X - Y)

ans4 = 2 * C * min(X, Y)
ans5 = 10 ** 18
ans6 = 10 ** 18
if X > Y:
    temp1 = A * t
    temp2 = 2 * C * t
    ans5 = ans4 + min(temp1, temp2)
else:
    temp1 = B * t
    temp2 = 2 * C * t
    ans6 = ans4 + min(temp1, temp2)

print(min(ans0,ans1, ans2, ans3, ans5, ans6))

Submission status: Accepted

Solution code:
import copy
import math

# a = get_int()
def get_int():
    return int(input())
# a = get_string()
def get_string():
    return input()
# a_list = get_int_list()
def get_int_list():
    return [int(x) for x in input().split()]
# a_list = get_string_list():
def get_string_list():
    return input().split()
# a, b = get_int_multi()
def get_int_multi():
    return map(int, input().split())
# a_list = get_string_char_list()
def get_string_char_list():
    return list(str(input()))
# print("{} {}".format(a, b))
# for num in range(0, a):
# a_list[idx]
# a_list = [0] * a
'''
while (idx < n) and ():

    idx += 1
'''

def main():

    a, b, c, x, y = get_int_multi()
    ans = 100000 * 5000 * 2

    for i in range(0,x+1):

        for ii in (max(0,(x - i) * 2), max(0,(y - i) * 2, (x - i) * 2)):
            price = i * a

            price += ii * c
            cnt_b = max(0, y - (ii // 2))
            price += cnt_b * b
            ans = min(ans, price)

    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def solve():
    A_yen, B_yen, AB_yen, A_mai, B_mai = list(map(int, input().split()))
    AB_average = (A_yen + B_yen)/2
    if (AB_average > AB_yen):
        if(2*AB_yen >= A_yen and 2*AB_yen >= B_yen):
            kakaku = AB_yen*2*min(A_mai, B_mai)
            if(A_mai > B_mai):
                kakaku += A_yen * (A_mai - min(A_mai, B_mai))
            else:
                kakaku += B_yen * (B_mai - min(A_mai, B_mai))
            print(kakaku)
        elif(2*AB_yen < A_yen and 2*AB_yen >= B_yen):
            kakaku = AB_yen*2*min(A_mai, B_mai)
            if(A_mai > B_mai):
                kakaku += 2*AB_yen * (A_mai - min(A_mai, B_mai))
            else:
                kakaku += B_yen * (B_mai - min(A_mai, B_mai))
            print(kakaku)
        elif(2*AB_yen >= A_yen and 2*AB_yen < B_yen):
            kakaku = AB_yen*2*min(A_mai, B_mai)
            if(A_mai > B_mai):
                kakaku += A_yen * (A_mai - min(A_mai, B_mai))
            else:
                kakaku += 2*AB_yen * (B_mai - min(A_mai, B_mai))
            print(kakaku)
        elif(2*AB_yen < A_yen and 2*AB_yen < B_yen):
            kakaku = AB_yen*2*min(A_mai, B_mai)
            if(A_mai > B_mai):
                kakaku += 2*AB_yen * (A_mai - min(A_mai, B_mai))
            else:
                kakaku += 2*AB_yen * (B_mai - min(A_mai, B_mai))
            print(kakaku)
    else:
        kakaku = A_yen * A_mai + B_yen * B_mai
        print(kakaku)


if __name__ == "__main__":
    solve()

Submission status: Accepted

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

l = []

#パターン１ AとBだけ作るとき
price1 = A * X + B * Y
l.append(price1)

#パターン2 AB分割とあまり調整
if X > Y:
    if A < 2*C:
        price2 = 2 * Y * C + A * abs(X-Y)
        l.append(price2)
    else:
        price3 = 2 * Y * C + C * abs(X-Y) * 2
        l.append(price3)
elif X < Y:
    if B < 2*C:
        price4 = 2 * X * C + B * abs(Y-X)
        l.append(price4)
    else:
        price5 = 2 * X * C + C * abs(Y-X) * 2
        l.append(price5)

else:
    price6 = 2 * X * C
    l.append(price6)


print(min(l))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    A, B, C, X, Y = map(int, input().split())
    min_cost = 2*max(X, Y)*C
    for c in range(0, 2*pow(10, 5)+2, 2):
        a = X-c//2
        b = Y-c//2
        if a>=0 and b>=0:
            cost = A*a+b*B+C*c
            min_cost = min(cost, min_cost)
    print(min_cost)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

#ABピザの最大枚数
limit = max(X,Y)*2
Min = 10**10

for i in range(limit+1):
    a=0
    b=0
    c=0
    
    if i/2 < X:
        a = (X-int(i/2)) *A
    if i/2 < Y:
        b= (Y-int(i/2))*B    
        
    c = i*C
    
    Min = min(Min,a+b+c)
    
    
    
print(Min)

Submission status: Accepted

Solution code:
#関数リスト
import sys
input = sys.stdin.readline


def RD(): return input().rstrip()
def I(): return int(input().rstrip())
def MI(): return map(int, input().split())
def MF(): return map(float,input().split())
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float,input().split()))

def main():
    A, B, C, X, Y = MI()
    result = float('inf')
    result = min(result,int(A*X+B*Y))
    temp = min(X,Y)
    result = min(result,int(C*temp*2+(X-temp)*A+(Y-temp)*B))
    result = min(result, int(max(X, Y)*C*2))
    print(result)
    
    
if __name__ == "__main__":
    main()

Submission status: Accepted

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

res = 0

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

else:
    res = A * X + B * Y

print(res)

Submission status: Accepted

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

total_AtoC = C * 2 * X + max((Y - X) * B, 0)
total_BtoC = C * 2 * Y + max((X - Y) * A, 0)
total_AB = A * X + B * Y

ans = min(total_AtoC, total_BtoC, total_AB)

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
A,B,C,X,Y=list(map(int, input().split()))
mini=1*10**10
Z=max(X,Y)
for i in range(Z+1):
  sum=A*(max(X-i,0))+B*max(Y-i,0)+C*2*i
  if sum<mini:
    mini=sum
print(mini)

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b,c,x,y=[int(x) for x in input().split()]
p=0
if a>=c and b>=c:
  p_1=c*min(x,y)*2
  if x>y:
    p_1+=a*(x-y)
  elif y>x:
    p_1+=b*(y-x)
  p_2=c*max(x,y)*2
  p=min(p_1,p_2)
elif a<=c and b<=c:
  p=a*x+b*y
elif a<=c and c<=b:
  p_1=a*x+b*y
  p_2=c*min(x,y)*2
  if x>y:
    p_2+=a*(x-y)
  elif y>x:
    p_2+=b*(y-x)
  p_3=c*max(x,y)*2
  p=min(p_1,p_2,p_3)
elif b<=c and c<=a:
  p_1=a*x+b*y
  p_2=c*min(x,y)*2
  if x>y:
    p_2+=a*(x-y)
  elif y>x:
    p_2+=b*(y-x)
  p_3=c*max(x,y)*2
  p=min(p_1,p_2,p_3)
print(p)

Submission status: Accepted

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

c *= 2

MIN=10**9

tmp = a*x + b*y
if tmp < MIN: MIN=tmp
  
if x <= y:
  tmp = c*x + (y-x)*b
  if tmp < MIN: MIN=tmp

else:
  tmp = c*y + (x - y)*a
  if tmp < MIN: MIN=tmp

tmp = c*max(x,y)
if tmp < MIN: MIN=tmp
  
print(MIN)

Submission status: Accepted

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

ans = 0

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

print(ans)

Submission status: Accepted

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

ans = float('inf')
for i in range(0,2*max(x,y)+1,2):
    ab = i
    x_tmp = x - i//2
    y_tmp = y - i//2
    tmp = max(0,a*x_tmp) + max(0,b*y_tmp) + c*i
    if tmp < ans:
        ans = tmp
print (ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A, B, C, X, Y = map(int, input().split())
ret = A * X + B * Y
x = 0
y = 0
c = 0
while (X + Y) * 2 > c :
    c += 2
    x += 1
    y += 1
    ret = min(ret, A * max(0, X - x) + B * max(0, Y - y) + c * C)
print(ret)

Submission status: Accepted

Solution code:
A, B, C, X, Y = map(int, input().split())
ret = A * X + B * Y
x = 0
y = 0
c = 0
while (X + Y) * 2 > c :
    c += 2
    x += 1
    y += 1
    tmp = A * max(0, X - x) + B * max(0, Y - y) + c * C
    ret = min(ret, tmp)
print(ret)

Submission status: Accepted

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

A,B,C,X,Y=map(int,input().split())
if X>Y: 
    X,Y=Y,X
    A,B=B,A
                # ここまでで、X<=Yが保証された


nomal=X*A+Y*B
buyCuntilX=2*X*C+(Y-X)*B
allC=2*X*C+(Y-X)*2*C

print(min(nomal,buyCuntilX,allC))

Submission status: Accepted

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

Submission status: Accepted

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

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

print(min(p))

Submission status: Accepted

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

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

XY = 0
ans = 10 ** 9
while XY // 2 <= max(X,Y):
  price = XY * C
  price += max(X - (XY // 2), 0) * A + max(Y - (XY // 2), 0) * B
  if ans > price:
    ans = price
  XY += 1
    
print(ans)

Submission status: Accepted

Solution code:
import math
from math import gcd
INF = float("inf")

import sys
input=sys.stdin.readline
import itertools

def main():
    a,b,c,x,y = map(int, input().split())
    num = max(x,y)
    ans = INF
    for i in range(0,num*2+1,2): # cをi枚買うとする
        half = i//2
        c_cst = i*c
        a_cst = max(x-half,0)*a
        b_cst = max(y-half,0)*b
        ans = min(ans,(c_cst+a_cst+b_cst))
    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 :
    print(x*a+y*b)
else :
    if x <= y :
        print(min(2*x*c+(y-x)*b,2*y*c))
    else:
        print(min(2*y*c+(x-y)*a,2*x*c))

Submission status: Accepted

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

min_cost = float('inf')
for ab in range(max(X + 1, Y + 1)):
    cost = ab * C
    cost += A * max(0, X - ab)
    cost += B * max(0, Y - ab)
    if min_cost > cost:
        min_cost = cost
print(min_cost)

Submission status: Accepted

Solution code:
A,B,C,X,Y = map(int,input().split())
ans = float("inf")
MAX = max(X,Y)*2
for i in range(0,MAX+1,2): #ABハーフを何枚買うか？必ず偶数枚
  #print(i,X-i//2,Y-i//2)
  temp = A*max((X-i//2),0)+B*max((Y-i//2),0)+C*i
  ans = min(temp,ans)
print(ans)

Submission status: Accepted

Solution code:
from numba import njit


@njit
def solve(a, b, c, x, y):
    ans = 10000000000000000
    for i in range(100000 + 1):
        X = i * (2 * c) + max(0, x - i) * a + max(0, y - i) * b
        ans = min(ans, X)
    return ans


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

Submission status: Accepted

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

print(ans)

Submission status: Accepted

Solution code:
def resolve():
    import math
    a, b, c, x, y = map(int, input().split())
    ans = a*x + b*y
    #abの枚数だけ考える
    for i in range(1, max(x, y)+1):
        ab = i*2 #abピザを奇数個買うことはない
        total = ab*c + a*max(0, x-i) + b*max(0, y-i) #負の値を採らないようにmaxにしてる
        ans = min(ans, total)
    print(ans)
resolve()

Submission status: Accepted

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

lst = []

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

Submission status: Accepted

Solution code:
def main():
    a, b, c, x, y = (int(i) for i in input().split())
    v1 = 2*c*max(x, y)
    v2 = 2*c*min(x, y) + (y-x if x < y else x-y)*(b if x < y else a)
    v3 = a*x + b*y
    print(min(v1, v2, v3))


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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:
            ans += 2*c
            x -= 1
            y -= 1
        else:
            ans = ans+a+b
            x -= 1
            y -= 1
    elif x>0:
        if 2*c<a:
            ans += 2*c
            x -= 1
        else:
            ans += a
            x -= 1
    else:
        if 2*c < b:
            ans += 2*c
            y -= 1
        else:
            ans += b
            y -= 1
#    print(ans)

print(ans)

Submission status: Accepted

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

# あり得るのはすべてA,Bで買う．少ない方を満たすまで
import math
max_money = A*X + B*Y

# 次にAをすべて！ABで買ってみる
if X>Y:
    max_money = min(2*X*C,max_money)
else:
    max_money = min(max_money,2*X*C + (Y-X)*B)


# 次にBをすべて！ABで買ってみる
if Y>X:
    max_money = min(2*Y*C,max_money)
else:
    max_money = min(max_money,2*Y*C + (X-Y)*A)

print(max_money)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

if X > Y:
    v = A
else:
    v = B

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

print(ans)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
price_A, price_B, price_AB, num_A, num_B = map(int,input().split())
AandB = price_A * num_A + price_B * num_B
if num_A >= num_B:
    minAB = price_AB*num_B*2 + price_A*(num_A-num_B)
else:
    minAB = price_AB*num_A*2 + price_B*(num_B-num_A)
maxAB = price_AB * max(num_A, num_B) * 2
print(min(AandB, minAB, maxAB))

Submission status: Accepted

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

m=max(x,y)
ans=10**9+7
for e in range(m+1):
  ans=min(ans,2*e*c+a*max(0,x-e)+b*max(0,y-e))
  
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(10 ** 5 + 1):
    total = 2 * C * i + A * max(0, X - i) + B * max(0, Y - i)
    ans = min(total, ans)

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a, b, c, x, y = map(int, input().split())
max_count = max(x, y)
ans = 10**18

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

print(ans)

Submission status: Accepted

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


def main():
    a, b, c, x, y = map(int, input().split())
    c *= 2
    res1 = a * x + b * y
    res2 = c * max(x, y)
    res3 = c * x + max(0, y-x) * b
    res4 = c * y + max(0, x-y) * a
    print(min([res1, res2, res3, res4]))


if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

n_c = min(x, y) * 2
n_a = x - n_c // 2
n_b = y - n_c // 2
amount1 = a * n_a + b * n_b + c * n_c

n_c = max(x, y) * 2
n_a = max(x - n_c // 2, 0)
n_b = max(y - n_c // 2, 0)
amount2 = a * n_a + b * n_b + c * n_c

n_a = x
n_b = y
n_c = 0
amount3 = a * n_a + b * n_b + c * n_c

amount = min(amount1, amount2, amount3)

print(amount)

Submission status: Accepted

Solution code:
import sys

def I(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def main():
    a, b, c, x, y =MI()
    ans = float('inf')
    for i in range(0, max(x*2, y*2)+1, 2):
        p = a*max(0, x-i//2) + b*max(0, y-i//2) + c*i
        ans = min(ans, p)
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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