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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!

A, B, AB, num_A, num_B = map(int, input().rstrip().split(' '))

min_cost = A * num_A + B * num_B
min_cost = min(min_cost, AB * 2 * max(num_A, num_B))
if num_A == num_B:
    min_cost = min(min_cost, AB * (num_A + num_B))
elif num_A > num_B:
    min_cost = min(min_cost, A * (num_A - num_B) + AB * 2 * num_B)
elif num_A < num_B:
    min_cost = min(min_cost, B * (num_B - num_A) + AB * 2 * num_A)
    
print(min_cost)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-


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

minprice = float("inf")

for i in range(1000001):
    buya = max(0,x - int(i / 2))
    buyb = max(0,y - int(i / 2))
    buyc = i
    price = buya * a + buyb * b + buyc * c
    if price < minprice:
        minprice = price

print(minprice)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A, B, C, X, Y = map(int, input().split())
ans = 10**18
if Y < X:
    t = X
    X = Y
    Y = t
    t = A
    A = B
    B = t
for i in range(2 * Y + 1):
    if i % 2:
        continue
    x, y = max(0, X - i//2), max(0, Y - i//2)
    sub = C * i + A * x + B * y
    if sub < ans:
        ans = sub
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

#全てABピザ
ans1=max(x,y)*2*c
#AはABピザ　BはBピザ
ans2=x*2*c+max(y-x,0)*b
#BはABピザ　AはAピザ
ans3=y*2*c+max(x-y,0)*a
#全てAピザBピザ
ans4=a*x+b*y
print(min(ans1,ans2,ans3,ans4))

Submission status: Accepted

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

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

print(min(honest,diff,max_))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque, OrderedDict
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from math import ceil, floor
from sys import setrecursionlimit

import heapq
import itertools
import operator


inf = float('inf')


# globals
A, B, C, X, Y = 0, 0, 0, 0, 0


def set_inputs():
    global A, B, C, X, Y
    A, B, C, X, Y = get_li()
    return


def main():
    setrecursionlimit(100000)
    set_inputs()
    # ----------MAIN----------
    if 2 * C <= A + B:
        a = min(A, 2 * C)
        b = min(B, 2 * C)
        print(min(X, Y) * 2 * C + max(0, X - min(X, Y)) * a + max(0, Y - min(X, Y)) * b)
    else:
        print(A * X + B * Y)
    return
    # dp = [[0 for _ in range(Y + 1)] for _ in range(X + 1)]
    # for i in range(1, X + 1):
    #     dp[i][0] = dp[i-1][0] + A
    # for j in range(1, Y + 1):
    #     dp[0][j] = dp[0][j-1] + B
    # for i in range(1, X + 1):
    #     for j in range(1, Y + 1):
    #         dp[i][j] = min(
    #             dp[i-1][j] + A,
    #             dp[i][j-1] + B,
    #             dp[i-1][j-1] + C * 2)
    # print(dp[X][Y])
    # return


def get_int():
    return int(input())


def get_float():
    return float(input())


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


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


def get_lf():
    return [float(f) for f in input().split()]


def get_lc():
    return list(input().strip())


def get_data(n, types):
    if len(types) == 1:
        return [types[0](input()) for _ in range(n)]
    return zip(*(
        [t(x) for t, x in zip(types, input().split())]
        for _ in range(n)
    ))


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

gA_B = x * a + y * b
gAB = max(x,y) * c
if y > x:
  gAB_B = x * c + (y-x) * b
else:
  gAB_B = gAB
if x > y:
  gA_AB = (x-y) * a + y * c
else:
  gA_AB = gAB
  
print(min(gA_B, gAB, gA_AB, gAB_B))

Submission status: Accepted

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

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

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

Submission status: Accepted

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

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

print(ans)

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

Submission status: Accepted

Solution code:
a = list(map(int,input().split()))
A = a[0]
B = a[1]
C = a[2]
X = a[3]
Y = a[4]
if A + B <= 2*C:
    print(str(A*X + B*Y))
else:
    if X <= Y:
        #2X枚のABピザを作る。残りY-X枚のBピザが必要
        if B <= 2*C:
            print(str(2*X*C + (Y-X)*B))
        else:
            print(str(2*Y*C))
    else:
        if A <= 2*C:
            print(str(2*Y*C + (X-Y)*A))
        else:
            print(str(2*X*C))

Submission status: Accepted

Solution code:
from functools import reduce
from operator import add

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

print(min([C*i + A*max(0,X - i//2) + B*max(0,Y-i//2) for i in range(max(2*X, 2*Y)+1)]))

Submission status: Accepted

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

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

print(Ans)

Submission status: Accepted

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

s = 0

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

print(s)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math, string, itertools, fractions, heapq, collections, re,  array, bisect, sys, random, time, copy, functools
sys.setrecursionlimit(10**7)
inf = 10 ** 20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def pf(s): return print(s, flush=True)

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


"""
A+BよりもCのほうがお得な場合、XまたはYを買い切るまでCを買う
その後は、AかBで残っているものとAB*2で安い方を買う
"""
result = 0
if A+B >= C*2:
    # Cを購入する
    reduce_amount = min(X,Y)
    X -= reduce_amount
    Y -= reduce_amount
    result += C*2*reduce_amount

if X > 0:
    result += min(C*2*X, A*X)

if Y > 0:
    result += min(C*2*Y, B*Y)


print(result)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

def f(x,y):
    return x-y if x>y else 0

print(min(2*c*x + f(y,x)*b, 2*c*y + f(x,y)*a, a*x+b*y))

Submission status: Accepted

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

def f(x,y):
    return x-y if x>y else 0

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

print(ans)

Submission status: Accepted

Solution code:
A,B,C,X,Y=map(int,input().split())
ans=[]
if X>=Y:
    X,Y=Y,X
    A,B=B,A

ans.append(A*X+B*Y)
ans.append(2*C*X+B*(Y-X))
ans.append(2*C*max(X,Y))

print(min(ans))

Submission status: Accepted

Solution code:
A,B,C,X,Y=map(int,input().split())
#AB 
M=max(2*X,2*Y)
ans=10**9
for i in range(0,M+2,2):
    temp=i*C+max(0,X-(i//2))*A+max(0,Y-(i//2))*B
    ans=min(ans,temp)
print(ans)

Submission status: Accepted

Solution code:
def solve(string):
    a, b, c, x, y = map(int, string.split())
    if a + b <= 2 * c:
        return str(a * x + b * y)
    if 2 * c <= a and 2 * c <= b:
        return str(2 * c * max(x, y))
    base = 2 * c * min(x, y)
    diff = abs(x - y)
    cost = min(a, 2 * c) if x >= y else min(b, 2 * c)
    return str(base + cost * diff)


if __name__ == '__main__':
    print(solve(input()))

Submission status: Accepted

Solution code:
def solve(string):
    a, b, c, x, y = map(int, string.split())
    if a + b <= 2 * c:
        return str(a * x + b * y)
    if 2 * c <= a and 2 * c <= b:
        return str(2 * c * max(x, y))
    base = 2 * c * min(x, y)
    diff = abs(x - y)
    return str(base + min(a, 2 * c) * diff if x >= y else base + min(b, 2 * c) * diff)


if __name__ == '__main__':
    print(solve(input()))

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0
judge = 0 #X < Y: 0,X >= Y: 1
if(X < Y):
  judge = 0
else:
  judge = 1
  
#A,B それぞれ一枚買うとき //「Aセット」+「Bセット」//と//「Cセット」*2//
#の安いほうをたくさん買う
if((A+B) > C*2 ):
  if(judge == 0):#X < Y 
   ans += C*2*X
   #残りはBをY-X枚買う
   if( B < 2*C):
    ans += B*(Y-X) 
   else:
    ans += C*2*(Y-X)    
  elif(judge == 1):#Y <= X
   ans += C*2*Y 
   #残りはAをX-Y枚買う
   if( A < 2*C):
    ans += A*(X-Y) 
   else:
    ans += C*2*(X-Y)

else:
  if(judge == 0):#X < Y 
   ans += (A+B)*X
   #残りはBをY-X枚買う
   if( B < 2*C):
    ans += B*(Y-X) 
   else:
    ans += C*2*(Y-X)    
  elif(judge == 1):#Y <= X
   ans += (A+B)*Y 
   #残りはAをX-Y枚買う
   if( A < 2*C):
    ans += A*(X-Y) 
   else:
    ans += C*2*(X-Y)

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

print(res)

Submission status: Accepted

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


A = 0
B = 0
res = 0

if c*2 <= a+b:
    res += min(x,y)*2*c
    A = min(x,y)
    B = min(x,y)

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

Submission status: Accepted

Solution code:
A, B, C, X, Y = map(int, input().split())
# ナップザック問題、にするまでもない。
for i in range(max(X,Y)+1):
    cost = i * 2*C + max(X-i, 0)*A + max(Y-i, 0) *B
    if i ==0:
        res = cost
    else:
        res = min(res, cost)
print(res)

Submission status: Accepted

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

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

print(price)

Submission status: Accepted

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

Submission status: Accepted

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

print(cost)

Submission status: Accepted

Solution code:
A, B, C, X, Y = map(int, input().split())
 
totalA1 = A * X
totalA2 = C * X * 2
totalB1 = B * Y
totalB2 = C * Y * 2
 
totalAB = A * X + B * Y
 
totalAC = C * Y * 2
if X > Y:
    totalAC += (X - Y) * A
 
totalCB = C * X * 2
if Y > X:
    totalCB += (Y - X) * B
 
totalCC = max(X, Y) * C * 2
 
print(min(totalAB, totalAC, totalCB, totalCC))

Submission status: Accepted

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

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

Submission status: Accepted

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

if x >= y:
	answer = (minab * y) + (mina * (x-y))
else:
	answer = (minab * x) + (minb * (y-x))
	
print(answer)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on 2019/3/16
Solved on 2019/3/
@author: shinjisu
"""


# ABC 095 C Half and Half
#import math
#import numpy as np

def getInt(): return int(input())

def getIntList(): return [int(x) for x in input().split()]
# def getIntList(): return np.array(input().split(), dtype=np.longlong)

def zeros(n): return [0]*n
# def zeros(n): return np.zeros(n, dtype=np.longlong)

def getIntLines(n): return [int(input()) for i in range(n)]
"""
def getIntLines(n):
    data = zeros(n)
    for i in range(n):
        data[i] = getInt()
    return data
"""

def zeros2(n, m): return [zeros(m)]*n # obsoleted zeros((n, m))で代替

def getIntMat(n, m):  # n行に渡って、1行にm個の整数
    #mat = zeros((n, m))
    mat = zeros2(n, m)
    for i in range(n):
        mat[i] = getIntList()
    return mat

ALPHABET = [chr(i+ord('a')) for i in range(26)]
DIGIT = [chr(i+ord('0')) for i in range(10)]
N1097 = 10**9 + 7
INF = 10**18

class Debug():
    def __init__(self):
        self.debug = True
 
    def off(self):
        self.debug = False
 
    def dmp(self, x, cmt=''):
        if self.debug:
            if cmt != '':
                print(cmt, ':  ', end='')
            print(x)
        return x


def prob():
    d = Debug()
    d.off()
    A, B, C, X, Y = getIntList()
    d.dmp((A, B, C, X, Y),'A, B, C, X, Y')
    pt1 = A*X + B*Y
    pt2 = A*X + C*2*Y
    pt3 = C*2*X + B*Y
    pt4 = C*2*min(X, Y)+ C*2*(max(X, Y)-min(X, Y))
    if X > Y:
        pt5 = C*2*min(X, Y)+ A*(X-min(X, Y))
    else:
        pt5 = C*2*min(X, Y)+ B*(Y-min(X, Y))

    yen = min(pt1, pt2, pt3, pt4, pt5)
    d.dmp((pt1, pt2, pt3, pt4, pt5), 'pt1, pt2, pt3, pt4, p5')
    d.dmp(yen, 'yen')
    return yen


ans = prob()
if ans is None:
    pass
elif type(ans) == tuple and ans[0] == 1:  # 1,ans
    for elm in ans[1]:
        print(elm)
else:
    print(ans)

Submission status: Accepted

Solution code:
# /user/bin/python
# -*- coding: utf-8 -*-
import sys
import math

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

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

if A > 2*C and X > 0:
  ans += 2*C*math.ceil(X)
  X = 0

if B > 2*C and Y > 0:
  ans += 2*C*math.ceil(Y)
  Y = 0

if X > 0:
  ans += A*math.ceil(X)

if Y > 0:
  ans += B*math.ceil(Y)

print(ans)

Submission status: Accepted

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


def main():
    print(
        min(A * X + B * Y,
            2 * max(X, Y) * C,
            2 * min(X, Y) * C + (B if X < Y else A) * abs(X - Y)))
    return


main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(cost)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
a, b, c, x, y=map(int, input().split())
ans=10**9
for i in range(2*max(x, y)+1):
    if 2*x-i>0:
        aa=math.ceil((2*x-i)/2)*a
    else:
        aa=0
    if 2*y-i>0:
        bb=math.ceil((2*y-i)/2)*b
    else:
        bb=0
    res=aa+bb+i*c
    ans=min(ans, res)
print(ans)

Submission status: Accepted

Solution code:
A , B , C , X , Y = map(int,input().split())
# 場合分けして考える
# 全てABピザ、
# 可能な限りAB、余りをA or B
# 全てA or B
# 上記の３パターンのうち、最も小さな金額が回答？
AB = max(X, Y) * 2 * C
ABandAorB = min(X,Y)* 2 * C + ( ((X-Y)* A  ) if  X > Y else ((Y -X) *B))
AorB = X * A + Y * B
print(min(AB,ABandAorB ,AorB ))

Submission status: Accepted

Solution code:
def half_and_half(
        A: int, B: int, C: int, X: int, Y: int) -> int:
    """
    :param A: A ピザの値段
    :param B: B ピザの値段
    :param C: AB ピザの値段
    :param X: A ピザの必要数
    :param Y: B ピザの必要数
    """
    min_price = float('inf')
    for num_ab in range(max(X, Y)+1):
        num_a, num_b = max(0, X-num_ab), max(0, Y-num_ab)
        price = num_a*A + num_b*B + 2*num_ab*C
        min_price = min(min_price, price)

    return min_price


if __name__ == "__main__":
    A, B, C, X, Y = map(int, input().split())
    ans = half_and_half(A, B, C, X, Y)
    print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A, B, C, X, Y = map(int,input().split())
ans = A*X + B*Y
ans = min(ans, C*X*2 + B*max(0, Y-X))
ans = min(ans, C*Y*2 + A*max(0, 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):
    # > なお、ピザの組み替えにより、必要な量を超えたピザが発生しても構いません。
    val_min = 5001 * (X+Y)
    for z in range(0, 2*max(X, Y)+1, 2):
        x = max(0, X - z//2)
        y = max(0, Y - z//2) 
        val_min_cond = A*x + B*y + C*z
        #print(x,y,z,val_min_cond)
        val_min = val_min_cond if val_min_cond < val_min else val_min
    print(val_min)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    X = int(next(tokens))  # type: int
    Y = int(next(tokens))  # type: int
    solve(A, B, C, X, Y)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b,c,x,y=map(int,input().split())
p1=a*x+b*y
min=10**9
for i in range(10**5+1):
    p2=2*i*c+max(0,x-i)*a+max(0,y-i)*b
    if p2<min:
        min=p2
if min<p1:
    print(min)
else:
    print(p1)

Submission status: Accepted

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


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a, b, c, x, y = map(int, input().split())
center = (a + b) / 2
res = 0
if center >= c:
    buy = min(x, y)
    res += buy * 2 * c
    x -= buy
    y -= buy
if x > 0 and a >= c * 2:
    res += x * 2 * c
    x = 0
if y > 0 and b >= c * 2:
    res += y * 2 * c
    y = 0
res += a * x
res += b * y
print(res)

Submission status: Accepted

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

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

print(answer)

Submission status: Accepted

Solution code:
import sys

def main():
  input = sys.stdin.readline
  A, B, C, X, Y = map(int, input().split())
  ans = float('INF')
  for i in range(max(X, Y)+1):
    cur = C * 2 * i + max(0, X - i) * A + max(0, Y - i) * B
    ans = min(ans, cur)
  print(ans)


if __name__ == '__main__':
  main()

Submission status: Accepted

Solution code:
import sys

def main():
  input = sys.stdin.readline
  A, B, C, X, Y = map(int, input().split())
  n = max(X, Y)
  ans = float('INF')
  for i in range(max(X, Y)+1):
    cur = C * 2 * i + max(0, X - i) * A + max(0, Y - i) * B
    ans = min(ans, cur)
  print(ans)


if __name__ == '__main__':
  main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import stdin
a, b, c, x, y = [int(x) for x in stdin.readline().rstrip().split()]
print(min([i*2*c+max(0, x-i)*a+max(0, y-i)*b for i in range(10**5+1)]))

Submission status: Accepted

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

money = [A*X+B*Y, 2*C*max(X,Y)]
n = min(X, Y)
x, y = X - n, Y - n
money.append(A*x+B*y+2*C*n)
money.append(A*n+B*n+2*C*(max(X,Y)-n))
print(min(money))

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
# ----------------------------------------------------------------
# Use Solve Function

def solve(lines):
    A,B,C,X,Y = map(int, lines.pop(0).split(' '))
    res = 0
    AB = (A + B)/2
    res = min(AB, C) * min(X, Y) * 2

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

    print(int(res))

lines = [x.strip() for x in sys.stdin.readlines()]

#
# solve !!
#
solve(lines)

Submission status: Accepted

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

Submission status: Accepted

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

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)+1):
    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())
p = [a,b]
xy = [x,y]
if a+b <= c*2:
    print(a*x+b*y)
else:
    if p[xy.index(max(xy))] > c*2:
        print(c*2*max(xy))
    else:
        print(c*2*min(xy) + p[xy.index(max(xy))]*(max(xy)-min(xy)))