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())
m=max(X, Y)
print(min([C*2*i+A*max(0, X-i)+B*max(0, Y-i) for i in range(m+1)]))

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

Submission status: Accepted

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

def solve(A: int, B: int, C: int, X: int, Y: int):
    ans = 10**9
    if A + B < 2 * C:#C=0
        ans = A*X + B*Y
    else:#C>1
        #Aを2*Cで補うときの利益 > Bを2*Cで補うときの利益
        if (A-2*C)*X + B*max(Y-X, 0) > (B-2*C)*Y + A*max(X-Y, 0):
            #A=0
            ans = 2*C*X + max(Y-X, 0)*B
        else:#B=0
            ans = 2*C*Y + max(X-Y, 0)*A
        if 2*C < A and 2*C < B:
            ans = min(ans, 2*C*max(X,Y))
    print(ans)

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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


def solve(A: int, B: int, C: int, X: int, Y: int):
    ans = 10**9
    if A + B < 2 * C:#C=0
        ans = A*X + B*Y
    else:#C>1
        #Aを2*Cで補うときの利益 > Bを2*Cで補うときの利益
        if (A-2*C)*X + B*max(Y-X, 0) > (B-2*C)*Y + A*max(X-Y, 0):
            #A=0
            ans = 2*C*X + max(Y-X, 0)*B
        else:#B=0
            ans = 2*C*Y + max(X-Y, 0)*A
        if 2*C < A and 2*C < B:
            ans = min(ans, 2*C*max(X,Y))
    print(ans)

# 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:
#!/usr/bin/env python3
import sys


def solve(A: int, B: int, C: int, X: int, Y: int):
    ans = 10**9
    if Y > X:
        bigger_y = 1
        bigger_x = 0
    elif Y == X:
        bigger_y = 1
        bigger_x = 1
    else:
        bigger_y = 0
        bigger_x = 1

    if A + B < 2 * C:#C=0
        ans = A*X + B*Y
    else:#C>1
        #Aを2*Cで補うときの利益 > Bを2*Cで補うときの利益
        if A*X - 2*C*X + B*(Y-X)*bigger_y > B*Y - 2*C*Y + A*(X-Y)*bigger_x:
            #A=0
            if bigger_x:
                ans = 2*C*X
            else:
                ans = 2*C*X + (Y-X)*B

        #Aを2*Cで補うときの利益 <= Bを2*Cで補うときの利益
        else:
            #B=0
            if bigger_y:
                ans = 2*C*Y
            else:
                ans = 2*C*Y + (X-Y)*A
        if 2*C < A and 2*C < B:
            ans = min(ans, 2*C*max(X,Y))
    print(ans)

# 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 = [int(i) for i in input().split()]
ans = (a + b + c) * (x + y)
for i in range(max(x, y) + 1):
  ans = min(2 * c * i + a * max(x - i, 0) + b * max(y - i, 0), ans)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#  095C
import sys
A,B,C,x,y = map(int, sys.stdin.readline().split())

ans = float('inf')
for i in range(0, 2*max(x, y)+1, 2):
    tmp = A*max(x-i//2, 0) + C*i + B*max(y-i//2, 0)
    #print(tmp, i)
    if ans > tmp:
        ans = tmp
print(ans)

Submission status: Accepted

Solution code:
import sys
A, B, C, x, y = map(int, sys.stdin.readline().split())

ans = float('inf')
for i in range(0, 2*max(x, y)+1, 2):
    tmp = A*max(x-i//2, 0) + C*i + B*max(y-i//2, 0)
    if tmp < ans:
        ans = tmp
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

print(cost)

Submission status: Accepted

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

#1≤A,B,C≤5000
#1≤X,Y≤10**5

#愚直解　TLEする。
#minimum_cost = 5000*A + 5000*B +5000*C
#
#for i in range(0,X+1):
#    for j in range(0,Y+1):
#        #残りの必要枚数は?
#        remain = max(X-i,Y-j) 
#        cost = A*i + B*j + C*(remain*2) #残り枚数が多い方の2倍の枚数、ABを買う
#        if minimum_cost > cost:
#            minimum_cost = cost
#
#print(minimum_cost)

minimum_cost = X*A + Y*B + (X+Y)*C

if X>Y:
    for A_pizza in range(0,X+1):
        AB_pizza = (X-A_pizza)*2 #Aピザの残りの必要枚数からABピザの購入枚数が求まる

        if Y - AB_pizza//2 > 0:
            B_pizza = Y - AB_pizza//2 #ABピザの購入枚数からBピザの購入枚数が求まる。ただしマイナスになるなら足りてるので買わない
        else:
            B_pizza = 0

        cost = A*A_pizza + B*B_pizza + C*AB_pizza #残り枚数が多い方の2倍の枚数、ABを買う

        #print(A_pizza,B_pizza,AB_pizza,cost)

        if minimum_cost > cost:
            minimum_cost = cost
            
else:
    for B_pizza in range(0,Y+1):
        AB_pizza = (Y-B_pizza)*2 #Aピザの残りの必要枚数からABピザの購入枚数が求まる

        if X - AB_pizza//2 > 0:
            A_pizza = X - AB_pizza//2 #ABピザの購入枚数からBピザの購入枚数が求まる。ただしマイナスになるなら足りてるので買わない
        else:
            A_pizza = 0

        cost = A*A_pizza + B*B_pizza + C*AB_pizza #残り枚数が多い方の2倍の枚数、ABを買う

        #print(A_pizza,B_pizza,AB_pizza,cost)

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

#入力の大小関係が異なるパターンに注意

Submission status: Accepted

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

#注文パターンを列挙する
#1. AとBのみを頼む
#2. CをAを満たすだけ頼んで、残りはBを買う
#3. CをBを満たすだけ頼んで、残りはAを買う
#4. Cのみを頼む <- 上記パターンに内包できそう

#Cは2の倍数ずつしか注文されない

#1
ans_1 = a*x + b*y
#2
ans_2 = c*x*2 + max(0, (y-x)*b)
#3
ans_3 = c*y*2 + max(0, (x-y)*a)
#4
ans_4 = c*max(x, y)*2

ans = min(ans_1, ans_2, ans_3, ans_4)
print(ans)

Submission status: Accepted

Solution code:
A , B , C , X ,Y = map(int,input().split())
C_val = C * 2
ans = 0
if A + B >= C_val:
    if X >= Y:
        XYmax , XYmin = X , Y
        cmp = A
    else:
        XYmax , XYmin = Y , X
        cmp = B
    ans += XYmin * C_val
    remain = XYmax - XYmin
    if cmp >= C_val:
        ans += C_val * remain
    else:
        ans += cmp * remain
    print(ans)
else:
    print(A * X + B * Y)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

ANS = []
#ABがめっちゃ安くて c*max(x,y)*2 が最安
ans = c*max(x,y)*2
ANS.append(ans)

#ABが安くて c*min(x,y)*2 + (max(x,y)-min(x,y))*(a or b)
if x > y:
  ans = c*y*2 + (x-y)*a
else:
  ans = c*x*2 + (y-x)*b
ANS.append(ans)

#ABが別に安くないなら、a*x+b*y
ans = a*x+b*y
ANS.append(ans)

print(min(ANS))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

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

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


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

Submission status: Accepted

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

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

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

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

print(min(case1,case2,case3))

Submission status: Accepted

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

ans = float('inf')
for ab in range(0, max(X, Y)*2+1, 2):
    a = max(0, X - ab//2)
    b = max(0, Y - ab//2)
    ans = min(ans, A * a + B * b + C * ab)

print(ans)

Submission status: Accepted

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

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

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):
    price=2*C*i+A*max(0,X-i)+B*max(0,Y-i)
    if price<Ans:
        Ans=price

print(Ans)

Submission status: Accepted

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

if A*X+B*Y<A*(X-1)+B*(Y-1)+C*2:
    price=A*X+B*Y
else:
    if 2*C<A and 2*C<B:
        price=max(X,Y)*2*C
    elif 2*C<A and 2*C>B and X>Y:
        price=X*2*C
    elif 2*C>A and 2*C<B and X<Y:
        price=Y*2*C
    else:
        if X>Y:
            price=2*C*Y+A*(X-Y)
        else:
            price=2*C*X+B*(Y-X)

print(price)

Submission status: Accepted

Solution code:
def examC():
    A, B, C, X, Y = LI()
    ans = 0
    if A+B<=C*2:
        ans = A*X + B*Y
    else:
        Z = min(X,Y)
        ans = min(A,C*2)*max(X-Z,0) + min(B,C*2)*max(Y-Z,0) + C*Z*2
    print(ans)


import sys,copy,bisect,itertools,heapq,math
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()
mod = 10**9 + 7
inf = float('inf')

examC()

Submission status: Accepted

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

Submission status: Accepted

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

#fit x
price = 0
num_c = x * 2
price += c * num_c
if x < y:
  price += (y - x) * b
min_cost = min(min_cost, price)

#fit y
price = 0
num_c = y * 2
price += c * num_c
if x > y:
  price += (x - y) * a
min_cost = min(min_cost, price)

#buy each
min_cost = min(min_cost, a * x + b * y)

print(min_cost)

Submission status: Accepted

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

ans = float("inf")
ab_max = max(x*2, y*2) 
for ab in range(ab_max+1):
    a_buy = max(x - (ab // 2),0)
    b_buy = max(y - (ab // 2),0)
    tmp = a * a_buy + b * b_buy + ab * c
    if ans > tmp:
        ans = tmp

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
from collections import deque
def getN():
    return int(input())
def getList():
    return list(map(int, input().split()))
import math
import bisect
from logging import getLogger, StreamHandler, DEBUG, WARNING
logger = getLogger(__name__)
handler = StreamHandler()
handler.setLevel(DEBUG)
logger.setLevel(DEBUG)
# handler.setLevel(WARNING)
# logger.setLevel(WARNING)
logger.addHandler(handler)



# class SegTree():
#     def __init__(self, n):
#         self.value = [0 for i in range(n*2)]

# MOD = 10 ** 9 + 7

# def getinvmod(n):
#     return [pow(i, MOD-2, MOD) for i in range(n+1)]

def main():
    ans = 0
    a,b,c,x,y = getList()


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

    ans2 = (a * x + b * y)

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

    print(min(ans1, ans2, ans3))
    return

if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

print(money)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    a,b,c,x,y=map(int,input().split())
    ans=0

    # 常に x>=y としておく
    if(x<y):
        x,y=y,x
        a,b=b,a

    # はじめに a+b と 2c の大小で y を埋める
    if(a+b>=2*c):
        ans+=y*2*c
        x-=y
    else:
        ans+=y*b

    # 次に残った x を、a と 2c の大小で埋める
    if(a>=2*c):
        ans+=x*2*c
    else:
        ans+=x*a

    print(ans)
resolve()

Submission status: Accepted

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

ans = 10**10

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from sys import stdin
import numpy as np
a,b,c,x,y= [int(x) for x in stdin.readline().rstrip().split()]

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

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys, math
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
sys.setrecursionlimit(10**8)
inf = float('inf')
ans=count=0
f=g=h=0
a,b,c,x,y=map(int,input().split())
if a+b>2*c:
    f=1
if a>2*c:
    g=1
if b>2*c:
    h=1

if f:
    ans+=min(x,y)*c*2
    if x>=y:
        if g==1:
            ans+=(x-y)*c*2
        else:
            ans+=(x-y)*a
    else:
        if h==1:
            ans += (y-x)*c*2
        else:
            ans+=(y-x)*b
else:
    if g:
        ans+=x*2*c+y*b
    elif h:
        ans+=x*a+y*2*c
    else:
        ans+=x*a+y*b
print(ans)

Submission status: Accepted

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

# Cを購入する数をiとして、その時の最小値を求める
ans = 10 ** 9
for i in range(max(X + 1, Y + 1)):
    amount = C * 2 * i + A * max(X - i, 0) + B * max(Y - i, 0)
    ans = min(ans, amount)

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a, b, c, x, y = map(int, input().split())
ans = 999999999999999
for i in range(10 ** 5+1):
  	# maxの部分はx-iまたはy-iが負になったときに0を返すために用いてる
    ans = min(ans, i * 2*c + max(0, x-i) * a + max(0, y-i)*b)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

com=max(x, y) * (2 * c)
print(min(com,ans))

Submission status: Accepted

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

A, B, C, X, Y = [int(x) for x in input().strip().split()]
ans = 0

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

Submission status: Accepted

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

ans = pow(10, 5) * max(A, B, C) * 3
ab_max = (max(X, Y)+1) * 2
for ab in range(0, ab_max + 1, 2):
    x = max(0, X - ab//2)
    y = max(0, Y - ab//2)
    price = x * A + y * B + ab * C
    # print((x, y, ab), price)
    ans = min(ans, price)

print(ans)

Submission status: Accepted

Solution code:
#                         author:  kagemeka 
#                         created: 2019-11-07 12:33:44(JST)
import sys
# import collections
# import math
# import string
# import bisect
# import re
# import itertools
# import statistics
# import functools
# import operator

def main():
    a, b, c, x, y = (int(i) for i in sys.stdin.readline().split())
    if a + b <= c * 2:
        cost = a * x + b * y
    elif x >= y:
        atleast = y
        cost = c * atleast * 2
        remainder = x - atleast
        if a <= c * 2:
            cost += a * remainder
        else:
            cost += c * remainder * 2
    else:
        atleast = x
        cost = c * atleast * 2
        remainder = y - atleast
        if b <= c * 2:
            cost += b * remainder
        else:
            cost += c * remainder * 2 
    
    print(cost)
    
if __name__ == "__main__":
    # execute only if run as a script
    main()

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

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

Submission status: Accepted

Solution code:
a,b,c,x,y=map(int,input().split())
ans=10000000000
for i in range(0,max(x,y)*2+1,1):
    if x-i/2<=0 and y-i/2<=0:
        aa=0
        bb=0
    elif x-i/2<=0 and y-i/2>0:
        aa=0
        bb=y-i/2
    elif y-i/2<=0 and x-i/2>0:
        aa=x-i/2
        bb=0
    else:
        aa=x-i/2
        bb=y-i/2
    ab=aa*a+bb*b+i*c
    ans=min(ans,ab)
print(int(ans))

Submission status: Accepted

Solution code:
a,b,c,x,y = [int(i) for i in input().split()]
if a+b <= 2*c:
    ans = a*x + b*y
else:
    z = min(x,y)
    ans = min(max(x,y)*c*2,z * 2 * c + a*(x-z) + b*(y-z))

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
a,b,c,x,y=map(int,input().split())
lo=0 
hi=10**19
def check(mi): 
    m=max(x,y)
    if m*2*c<=mi:
        #print('sdfu')
        return 1 
    if a<c and b<c: 
        cost=a*x+b*y 
        #print('hf')
        return cost<=mi 
    if a>c and b>c:
        cost=0 
        mini=min(x,y)
        #print('hsdfiu')
        return mini*c*2+(-mini+x)*a+(-mini+y)*b<=mi 

    if a*x+b*y<=mi:
        return 1 
    mini=min(x,y)
    if mini*c*2+(x-mini)*a+(y-mini)*b<=mi:
      #  print('sf')
        return 1 
    return 0 
#print(check(1700))
#print(check(4700))
#print(check(100000000))
while lo<=hi:
    mi=(lo+hi)>>1 
    if check(mi):
        ans=mi 
        hi=mi-1 
    else:
        lo=mi+1 
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A,B,C,X,Y=map(int,input().split())
ans= min(A+B,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())
ans=A*X+B*Y
for i in range(max(X,Y)+1):
	ans=min(ans,2*C*i+A*max((X-i),0)+B*max((Y-i),0))

print(ans)

Submission status: Accepted

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


def main():
    import math
    import collections
    import itertools

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



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

Submission status: Accepted

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

Submission status: Accepted

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

ans = a * n_a + b * n_b
while ans > a * max(n_a - 1, 0) + b * max(n_b - 1, 0) + c * n_c:
    ans = a * max(n_a - 1, 0) + b * max(n_b - 1, 0) + c * n_c
    n_a -= 1
    n_b -= 1
    n_c += 2
    
print(ans)

Submission status: Accepted

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

res=0

if X>0 and Y>0:
        if A+B > 2*C: # must buy C pizza
                minxy = min(X,Y)
                res += 2 * C * minxy
                X -= minxy
                Y -= minxy

# here, X == 0 or Y == 0




if X > 0: # buy some A pizza
        if A > 2 * C: # buy 2X * AB pizza
                res += C * 2*X
                Y -= X
        else: # buy A pizza
                res += X * A

if Y > 0: # buy some B pizza
        if B > 2 * C:
                res += C*2*Y
        else:
                res+= Y * B

print(res)

Submission status: Accepted

Solution code:
def slove():
    import sys
    input = sys.stdin.readline
    a, b, c, x, y = list(map(int, input().rstrip('\n').split()))
    t = a * x + b * y
    t = min(t, max(x, y) * 2 * c)
    m = min(x, y)
    x -= m
    y -= m
    m = min(t, a * x + b * y + c * 2 * m)
    print(m)


if __name__ == '__main__':
    slove()

Submission status: Accepted

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

ans = max(A, B) * (X + Y)
for i in range(2 * 10 ** 5 + 100):
    c = i // 2
    x = i * C + max(X - c, 0) * A + max(Y - c, 0) * B
    ans = min(ans, x)

print(ans)

Submission status: Accepted

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

r = []

# Cピザを使わない
t1 = A * X + B * Y
r.append(t1)

# Cピザをmin(A*2, B*2)まで買う
x = min(X, Y)
ab = 2 * x
t2 = ab * C + (X - x) * A + (Y - x) * B
r.append(t2)

# Cピザで賄う
x = max(X, Y)
ab = 2 * x
t3 = ab * C
r.append(t3)

print(min(r))