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:
if __name__ == '__main__':
    A, B, C, X, Y = map(int, input().split())
    
    ans = 0
    
    X2 = X
    Y2 = Y
    mXY = min(X2, Y2)
    
    
    if C * 2 <= A + B:
        ans += mXY * 2 * C
    else:
        ans += mXY * A + mXY * B
        
    X2 -= mXY
    Y2 -= mXY
    
    
    if Y2 != 0:
        if B <= C * 2:
            ans += Y2 * B
        else:
            ans += Y2 * 2 * C
    elif X2 != 0:
        if A <= C * 2:
            ans += X2 * A
        else:
            ans += X2 * 2 * C
    
    print(ans)

Submission status: Accepted

Solution code:
# sys.stdin.readline
import sys

input = sys.stdin.readline


class AtCoder:
    def main(self):
        A, B, C, X, Y = map(int, input().split())
        print(min([max(X, Y) * 2 * C, A * X + B * Y, X * 2 * C + max(0, Y - X) * B, max(0, X - Y) * A + Y * 2 * C]))


# Run main
if __name__ == '__main__':
    AtCoder().main()

Submission status: Accepted

Solution code:
A, B, C, X, Y = map(int, input().rstrip("\n").split())
Z = min(X, Y)

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

print(min(ans))

Submission status: Accepted

Solution code:
#import pysnooper
#import os,re,sys,operator,math,heapq,string
#from collections import Counter,deque
#from operator import itemgetter
#from itertools import accumulate,combinations,groupby,combinations_with_replacement
from sys import stdin,setrecursionlimit
#from copy import deepcopy

setrecursionlimit(10**6)
input=stdin.readline

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
ip = list(map(int,input().split()))
a = ip[0]
b = ip[1]
c = ip[2]
xy = []
xy.append(ip[3])
xy.append(ip[4])

ans = (a+b+c)*max(xy)
for k in range(max(xy)+1):
	aa = xy[0] - k
	bb = xy[1] - k
	cc = 2*k
	if aa < 0:
		aa = 0
	if bb < 0:
		bb = 0
	tmp = aa*a + bb*b + cc*c
	if tmp < ans:
		ans = tmp

print(ans)

Submission status: Accepted

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


mini = 1000000000000

for i in range(max(x,y)+1):
    sum = (2*c*i) + (a *max(0, x-i) + (b * max(0, y-i)))
    if sum <= mini:
        mini = sum

print(mini)

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):
  if X - i > 0 and Y - i > 0:
    price = A * (X - i) + B * (Y - i ) + C * i * 2
  elif X - i <= 0 and Y - i > 0:
    price = B * (Y - i ) + C * i * 2
  elif X - i > 0 and Y - i <= 0:
    price = A * (X - i) + C * i * 2
  else:
    price = C * i * 2
  if ans > price:
    ans = price

print(ans)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
a,b,c,x,y=map(int,input().split())
ans1=x*a+y*b #aとbだけ
d=0
if x>y : d=a
else : d=b 
ans2=min(x,y)*c*2+(max(x,y)-min(x,y))*d #xとyの最小
ans3=max(x,y)*2*c
print(min(ans1,ans2,ans3))

Submission status: Accepted

Solution code:
A, B, C ,Req_A ,Req_B = map(int,input().split())
min = 10000000000000
end = True
result = 0

while (Req_A + Req_B) > 0:
    if 2*C < A+B and 0 < Req_A and 0 < Req_B:
        Req_B -= 1
        Req_A -= 1
        result += 2*C
    elif 2*C < A and 0 < Req_A:
        Req_A -= 1
        result += 2*C
    elif 2*C < B and 0 < Req_B:
        Req_B -= 1
        result += 2*C
    elif 0 < Req_A :
        Req_A -= 1
        result += A
    elif 0 < Req_B:
        Req_B -= 1
        result += B
print(result)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
#ARC096C
import copy
import sys
import math

#n = int(input())
tmp = input().split()
a,b,c,x,y = list(map(lambda a: int(a), tmp))

t=min(x,y)
u=max(x,y)

print(min(a*x+b*y, min(2*t*c+(x-t)*a+(y-t)*b, 2*u*c)))

Submission status: Accepted

Solution code:

a, b, c, x, y = [int(c) for c in input().split(' ')]
max_num_ab = 2 * max(x, y)
min_price = a * x + b * y
for num_ab in range(0, max_num_ab + 2, 2):
    price_ab = c * num_ab
    count_a = int(num_ab / 2)
    count_b = int(num_ab / 2)
    if count_a >= x:
        price_a = 0
    else:
        price_a = (x - count_a) * a

    if count_b >= y:
        price_b = 0
    else:
        price_b = (y -count_b) * b

    min_price = min(min_price, price_ab + price_a + price_b)
print(min_price)

Submission status: Accepted

Solution code:
#! /Library/Frameworks/Python.framework/Versions/3.7/bin/python3
A, B, C, X, Y = map(int, input().split())
if A + B >= C * 2:  # A1枚B1枚買うよりABピザ2枚買うほうがが安いので、まずは共通枚数分をなるべく多く買う
    if (X > Y and A > C * 2) or (X < Y and B > C * 2):  # 買いきった余りをCで買うか、AもしくはBで買うかの判定
        print(str(max(X, Y) * C * 2))
    else:
        if X >= Y:
            print(str(Y * C * 2 + (X - Y) * A))
        else:
            print(str(X * C * 2 + (Y - X) * B))
else:  # ABピザが高いので、個別に買う
    print(str(A*X+B*Y))

Submission status: Accepted

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

for c in range(max(X, Y)+1):
    if c < X:
        a = X - c
    else:
        a = 0

    if c < Y:
        b = Y - c
    else:
        b = 0

    if c == 0:
        min = a*A + b*B + c*C*2
    elif a*A + b*B + c*C*2 < min:
        min = a*A + b*B + c*C*2

print(min)

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

Submission status: Accepted

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

#print(a,b,c,x,y)

cost = a*x + b*y

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

s = [0,0,0]

s[0] = x*a + y*b

c_half_num = min(x,y)
s[1] = max((x-c_half_num),0)*a + max((y-c_half_num),0)*b + c_half_num*(c*2)

c_half_num = max(x,y)
s[2] = c_half_num * (c*2)

print(min(s))

Submission status: Accepted

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

Submission status: Accepted

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

    else:
        ans += x * 2 * c
        ans += (y-x) * b

elif c * 2 <= b:
    if y >= x:
        ans += y * 2 * c

    else:
        ans += y * 2 * c
        ans += (x - y) * a

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

    else:
        ans += x * 2 * c
        ans += (y - x) * b

else:
    ans = a * x + b * y

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

ans = 10 ** 9
max_xy = max(X, Y)
for i in range(max_xy + 1):
    tmp = 2 * C * i
    tmp += A * max(X-i, 0) + B * max(Y-i, 0)
    if tmp < ans:
        ans = tmp
print(ans)

Submission status: Accepted

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

mini = 1000000000000
for i in range(max(x,y)+1):
	summ = (2*c*i) + (a * max(0,x-i)) + (b * max(0,y-i))
	if summ < mini:
		mini = summ
print(mini)

Submission status: Accepted

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

min_cost = 1000000000

for i in range(0,2*max(X,Y) +1,2):
    cost = i * C + max(0,(Y - i//2))*B+ max(0,(X - i//2))*A
    if cost < min_cost:
        min_cost = cost

print(min_cost)

Submission status: Accepted

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

min_cost = 1000000000

if X <=Y:
    for i in range(0,2*Y +1,2):
        if 0<=i<=2*X:
            cost = i * C + (X - i//2)*A + (Y - i//2)*B
        elif i <= 2*Y:
            cost = i * C + (Y - i//2)*B
        if cost < min_cost:
            min_cost = cost
elif X >Y:
    for i in range(0,2*X +1,2):
        if 0<=i<=2*Y:
            cost = i * C + (X - i//2)*A + (Y - i//2)*B
        elif i <= 2*X:
            cost = i * C + (X - i//2)*A
        if cost < min_cost:
            min_cost = cost
print(min_cost)

Submission status: Accepted

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

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

Submission status: Accepted

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

for i in range(x+1):
    n = x - i
    if y >= n:
        pay = a*i + 2*n*c + (y-n)*b
    else:
        pay = a*i + 2*n*c
    if cost > pay:
        cost = pay

for i in range(y+1):
    n = y -i
    if x >= n:
        pay = b*i + 2*n*c + (x-n)*a
    else:
        pay = b*i + 2*n*c
    if cost > pay:
        cost = pay
print(cost)

Submission status: Accepted

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


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

print(count)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a, b, ab, x, y = map(int, input().split())
if a + b > ab*2:
  ab1 = True
else:
  ab1 = False

if a > ab*2:
  a1 = True
else:
  a1 = False

if b > ab*2:
  b1 = True
else:
  b1 = False

price = 0
if x > y:
  if ab1 is True:
    price += ab*2*y
    if a1 is True:
  	  price += ab*2*(x-y)
    else:
      price += a*(x-y)
  else:
    price += a*x + b*y
else:
  if ab1 is True:
    price += ab*2*x
    if b1 is True:
      price += ab*2*(y-x)
    else:
      price += b*(y-x)
  else:
    price += a*x + b*y
    
print(price)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

#1-AとBをそれぞれ買う場合
cost1 = a*x+b*y

#2-abを買えるだけ買う場合
cost2 = max(x,y)*2*c

#3-余りだけaまたはbで買う場合
cost_ab = min(x,y)*2*c    #abを買う
if  max(x,y) == x:
    tmp2 = (x-y)*a
else:
    tmp2 = (y-x)*b

cost3 = cost_ab + tmp2

print(min(cost1,cost2,cost3))

Submission status: Accepted

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


def read_h(typ=int):
    return list(map(typ, input().split()))


def read_v(n, m=1, typ=int):
    return [read_h() if m > 1 else typ(input()) for _ in range(n)]


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

    base_cnt = min(X, Y)
    ans = min(A + B, C * 2) * base_cnt + (X - base_cnt) * min(A, C * 2) + \
        (Y - base_cnt) * min(B, C * 2)
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

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


def read_h(typ=int):
    return list(map(typ, input().split()))


def read_v(n, m=1, typ=int):
    return [read_h() if m > 1 else typ(input()) for _ in range(n)]


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

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

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

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

ans = X * A + Y * B

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

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

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

Submission status: Accepted

Solution code:
row = list(map(int, input().split()))
min_pay = 5000 * 1e+5 * 2
if row[3] > row[4]:
    Z = row[3]
else:
    Z = row[4]
for z in range(2*Z+1):
    if z % 2 == 0:
        x = row[3] - z / 2
        y = row[4] - z / 2 
        if x < 0:
            x = 0
        if y < 0:
            y = 0
        pay = x*row[0] + y*row[1] + z*row[2]
        if pay < min_pay:
            min_pay = pay
            
print(int(min_pay))

Submission status: Accepted

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

print(cnta*A+cntb*B+cntc*C)

Submission status: Accepted

Solution code:
a,b,c,x,y = map(int,input().split())
min_total = a*x + b*y
for ci in range(max(x,y)*2+1):
  ai = max(0,x - ci//2)
  bi = max(0,y - ci//2)
  
  total = ai*a + bi*b + ci*c
  if min_total > total:# and (ai+ci//2 >= x) and (bi+ci//2 >= y):                 
    min_total = total    
print(min_total)

Submission status: Accepted

Solution code:
A, B, C, X, Y = map(int, input().split())
def calc(x, y):
    return A*x+B*y

mi = min(X, Y)
ma = max(X, Y)
print(min(calc(X,Y), calc(X-mi, Y-mi) + C*mi*2, C*ma*2))

Submission status: Accepted

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

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

Submission status: Accepted

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

cost = []
if x < y:
    cost.append(y*c*2)
    cost.append(c*x*2+(y-x)*b)
else:
    cost.append(x*c*2)
    cost.append(c*y*2+(x-y)*a)

cost.append(x*a+y*b)
    
print(min(cost))

Submission status: Accepted

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

Submission status: Accepted

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

_1=a*x+b*y

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

print(min(_1,_2,_3)  )

Submission status: Accepted

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

min_price = 100000 * 3 * 5000
for pizza_c in range(max(x, y) * 2 + 1):
        pizza_a = max(x - int(pizza_c / 2), 0)
        pizza_b = max(y - int(pizza_c / 2), 0)
        min_price = min(pizza_a * a + pizza_b * b + pizza_c * c, min_price)
print(min_price)

Submission status: Accepted

Solution code:
from itertools import*
from math import*
from collections import*
from heapq import*
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf = float("inf")
mod = 10**9+7
from functools import reduce
import sys
sys.setrecursionlimit(10**7)

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

if 2*C < A+B:
    ans = inf 
    for i in range(min(X,Y),max(X,Y)+1):
        ans = min(ans,max(0,(X-i))*A+max(0,(Y-i))*B+i*2*C)
    print(ans)

else:
    print(X*A+Y*B)

Submission status: Accepted

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

total=0
total2=0
if A+B>2*C:
    total+=2*C*min(X,Y)
    if X>Y:
        total+=(X-Y)*A
    else:
        total+=(Y-X)*B
    total2+=2*C*max(X,Y)
else:
    total = X*A+Y*B
    print(total)
    exit()
print(min(total,total2))

Submission status: Accepted

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

min_money = float('inf')

for k in range(max(X,Y) + 1):
    i = X - k
    j = Y - k
    sum_momey = 2 * k * C
    if (i > 0):
        sum_momey += i * A
    if (j > 0):
        sum_momey += j * B
    if min_money > sum_momey:
        min_money = sum_momey

print(min_money)

Submission status: Accepted

Solution code:
a, b, c, x, y = list(map(int, input().split()))
result = [a*x+b*y]

if x > y:
  result.append((y*2*c) + ((x-y)*a))
  result.append(y*b+(x*(c*2)))
else:
  result.append((x*2*c) + ((y-x)*b))
  result.append(x*a+(y*(c*2)))

result.append(c*2*max(x,y))
print(min(result))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A,B,C,X,Y = list(map(int,input().split()))
c = [X,Y]
total = 0
if A+B >= 2*C:
  total += 2*C*(min(c))
  if X > Y:
    if A >= 2*C:
      total += 2*C*(X-Y)
    else:
      total += A*(X-Y)
  else:
    if B >= 2*C:
      total += 2*C*(Y-X)
    else:
      total += B*(Y-X)
else:
  total += A*X + B*Y

print(total)

Submission status: Accepted

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

separate = A * X + B * Y
middle = X * 2 * C + B * (Y - X) if min(X, Y) == X else Y * 2 * C + A * (X - Y)
whole = max(X, Y) * 2 * C

print(min(separate, middle, whole))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a, b, c, x, y = map(int, input().split())
result = 0
hlf = c*2

if a+b < hlf:  # example 2
    result = a*x + b*y
else:  # example 1, 3
    result = min(x, y)*hlf
    rem = abs(x-y)
    tmp = a*rem if max(x, y) == x else b*rem

    if hlf*rem < tmp:
        tmp = hlf*rem
    result += tmp

print(result)

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

Submission status: Accepted

Solution code:
A, B, C, X, Y = map(int, input().split())
# 個別に買う
v1 = A * X + B * Y
# 少ない方に合わせてセットを買い、足りない分を買い足す
if X >= Y:
    v2 = C * 2 * Y + (X - Y) * A
else:
    v2 = C * 2 * X + (Y - X) * B
# すべてセットで買う
v3 = C * 2 * max([X, Y])
print(min([v1, v2, v3]))

Submission status: Accepted

Solution code:
a = list(map(int, input().split()))
sum = 0

if a[0] / 2 + a[1] / 2 < a[2]:
    for i in range(a[3]):
        sum += a[0]
    for i in range(a[4]):
        sum += a[1]
else:
    if a[3] <= a[4]:
        for i in range(a[3]):
            sum += a[2]*2
        if a[1] < a[2] * 2:
            for i in range(a[4] - a[3]):
                sum += a[1]
        else:
            for i in range(a[4] - a[3]):
                sum += a[2]*2
    else:
        for i in range(a[4]):
            sum += a[2]*2
        if a[0] < a[2] * 2:
            for i in range(a[3] - a[4]):
                sum += a[0]
        else:
            for i in range(a[3] - a[4]):
                sum += a[2]*2
print(sum)

Submission status: Accepted

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

ans = 10**9
for i in range(10**6):
    pizza_AB = 2*i*C
    pizza_A = max(X-i,0)*A
    pizza_B = max(Y-i,0)*B
    if ans > pizza_AB+pizza_A+pizza_B:
        ans = pizza_AB+pizza_A+pizza_B

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

a = 0
b = 0
c = 0

ABcand = min([X, Y])
if A + B >= C * 2:
    c += ABcand * 2
else:
    a += ABcand
    b += ABcand

if X == ABcand:
    res = Y - ABcand
    if B * res >= C * res * 2:
        c += res * 2
    else:
        b += res
else:
    res = X - ABcand
    if A * res >= C * res * 2:
        c += res * 2
    else:
        a += res
print(A*a+B*b+C*c)

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

Submission status: Accepted

Solution code:
A,B,C,X,Y=map(int,input().split())
N=max(X,Y)
pay=0
for i in range(N+1):
    c=i*2
    a=max(0,X-i)
    b=max(0,Y-i)
    if pay==0:
        pay=A*a+B*b+C*c
    else:
        pay=min(pay,A*a+B*b+C*c)
print(pay)

Submission status: Accepted

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

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

for nc in range(0,max(X,Y)*2+1,2):
  tmp = max((X-nc//2),0)*A+max((Y-nc//2),0)*B+nc*C
  ans = min(ans,tmp)
print(ans)

Submission status: Accepted

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

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

    print(total)

main()

Submission status: Accepted

Solution code:
A,B,C,X,Y=map(int,input().split(' '))
ans=-1
for n_ab in range(max(X,Y)+1):
  n_a = max(X-n_ab, 0)
  n_b = max(Y-n_ab, 0)
  p = n_a*A+n_b*B+n_ab*2*C
  ans=p if ans==-1 or p<ans else ans
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

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*y + a*(x-y) +(10**10 if y > x else 0), 2*c*x + b*abs(y-x)+(10**10 if x > y else 0)))

Submission status: Accepted

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

best = 10**9
for c in range(max(X, Y)*2+1):
    a = X-c
    b = Y-c
    if a < 0:
        a = 0
    if b < 0:
        b = 0
    p = A*a + B*b + C*c*2
    if p < best:
        best = p

print(best)

Submission status: Accepted

Solution code:
a, b, c, x, y = map(int, input().split())
min_val = 2**30
if x < y:
    tmp = x
    x = y
    y = tmp
    tmp = a
    a = b
    b = tmp

for i in range(x + 1):
    k = (x - i) * 2
    k = 0 if k < 0 else k
    j = y - (k // 2)
    j = 0 if j < 0 else j
    val = i * a + j * b + k * c
    if val < min_val:
        min_val = val
print(min_val)

Submission status: Accepted

Solution code:
#! /usr/bin/python 
# -*- coding: utf-8 -*- 
#===============================================================================
# Date created  : 2019-03-30T11:10:44+09:00
# Date modified : 2019-03-30T11:10:44+09:00
# Author        : awk
# Description   : unanswered
#===============================================================================


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

for i in range(10**5 + 1):
    # 2i 枚のABピザを買う
    x = i
    y = i
    a = max(X - i, 0)
    b = max(Y - i, 0)
    cost.append(A * a + B * b + C * 2 * i)
print(min(cost))

Submission status: Accepted

Solution code:
import sys

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

a = min(A, 2*C)
b = min(B, 2*C)
ab = min(A+B, 2*C)
cost = 0

if ab < (a + b):
  if X == Y:
    print(ab * X)
    sys.exit()
  elif X > Y:
    cost += ab * Y
    if ab <= a:
      cost += ab * (X - Y)
      print(cost)
      sys.exit()
    else:
      cost += a * (X - Y)
      print(cost)
      sys.exit()
  else:       # (X < Y)
    cost += ab * X
    if ab <= b:
      cost += ab * (Y - X)
      print(cost)
      sys.exit()
    else:
      cost += b * (Y - X)
      print(cost)
      sys.exit()
else:
  print(a*X + b*Y)
  sys.exit()

Submission status: Accepted

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

Submission status: Accepted

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