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())

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

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

Submission status: Accepted

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

if a+b<2*ab:
  print(a*x+b*y)
else:
  amount = min(min(x,y)*2*ab+ (abs(x-y))*(a if x>y else b),max(x,y)*2*ab)
  print(amount)

Submission status: Accepted

Solution code:
s, t, c, x, y = list(map(int, input().split()))
a = [s, x]
b = [t, y]
if x > y:
    large = a
    least = b
else:
    large = b
    least = a
ans = 0
if s + t >= c * 2:
    ans += c * 2 * least[1]
    if large[0] > c * 2:
        ans += c * 2 * (large[1] - least[1])
    else:
        ans += large[0] * (large[1] - least[1])
else:
    ans += s * x + t * y
print(ans)

Submission status: Accepted

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

sum1 = a * x + b * y

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

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

print(min(sum1, sum2, sum3))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
A, B, C, X, Y = map(int, input().split())
ans = 0
if A+B < C*2:
    ans += (A+B)*min(X, Y)
else:
    ans += C * 2 * min(X, Y)
if X < Y:
    tmp = B*(Y-X)
else:
    tmp = A*(X-Y)
AB = C*abs(X-Y)*2
print(ans + min(tmp, AB))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
A, B, C, X, Y = map(int, input().split())
minXY = min(X, Y)
if A + B >= 2 * C:#C2枚を買う方が良い
  ans = 2 * C *minXY
  X, Y = X - minXY, Y - minXY
  if X == 0:
    if B > 2 * C:
      ans += 2 * C * Y
    else:
      ans += B * Y
  else:# Y == 0
    if A > 2 * C:
      ans += 2 * C * X
    else:
      ans += A * X
else:#それぞれの方が安い
  ans = A * X + B * Y
  
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def test():
    a,b,c,x,y = map(int,input().split())
    result = float("inf")
    for i in range(x+y):
        result = min(result,2*c*i + a*max(0,x-i) + b*max(0,y-i))
    print(result)


if __name__ == "__main__":
    test()

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
A,B,C,X,Y=map(int,input().split())

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

Submission status: Accepted

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

# AB購入数が決まるとA購入数とB購入数が決まるので、それを利用して総当りする

cost = set()
for n_AB in range(0, max(X,Y)*2 + 1, 2):
    n_A = max(0, X - n_AB//2)
    n_B = max(0, Y - n_AB//2)
    cost.add(n_A*A + n_B*B + n_AB*C)

print(min(cost))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
a,b,c,x,y = map(int,input().split())
pizza = [(x,a),(y,b)]
pizza.sort()
sp,sq = pizza[0][1],pizza[0][0]
lp,lq = pizza[1][1],pizza[1][0]


print(min(a*x+b*y,c*2*lq,c*2*sq+lp*(lq-sq)))

Submission status: Accepted

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

tmp1 = c * min(x, y) * 2
tmp2 = 0
if x < y:
    tmp2 = b * abs(x - y)

elif x > y:
    tmp2 = a * abs(x - y)

else:
    tmp2 = float("INF")

pattern1 = (a * x + b * y)
pattern2 = tmp1 + tmp2
pattern3 = c * max(x, y) * 2

print(min(pattern1, pattern2, pattern3))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

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

ans = 0
if A + B > 2 * C:
	ans += 2 * C * min(X, Y)
	idx = (X, Y).index(max(X, Y))
	left = abs(X - Y)
	if 2 * C < (A, B)[idx]:  # C を購入
		ans += 2 * C * left
	else:
		ans += (A, B)[idx] * left
else:
	ans = A * X + B * Y
print(ans)

Submission status: Accepted

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

a_cnt = 0
b_cnt = 0
c_cnt = 0

if A + B > C * 2:
    c_cnt += min(X,Y) * 2
else:
    a_cnt = b_cnt = min(X,Y)

if X > Y:
    if A < C * 2:
        a_cnt += X-Y
    else:
        c_cnt += (X-Y) * 2
elif Y > X:
    if B < C * 2:
        b_cnt += Y-X
    else:
        c_cnt += (Y-X) * 2
print(a_cnt * A + b_cnt * B + c_cnt * C)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b,c,x,y=[int(s) for s in input().split()]
if x<=y:
  A=a
  B=b
  C=c
  X=x
  Y=y
else:
  A=b
  B=a
  C=c
  X=y
  Y=x
#print([Y*2*C,X*2*C+(Y-X)*B,X*A+Y*B])
print(min([Y*2*C,X*2*C+(Y-X)*B,X*A+Y*B]))

Submission status: Accepted

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

minprice = 10 ** 10
XY_max = max(X,Y)

for i in range(XY_max + 1):
    nokori_X = max(X - i,0)
    nokori_Y = max(Y - i,0)

    tmp = i * 2 * C + nokori_X * A + nokori_Y * B
    minprice = min(tmp,minprice)

if minprice == 10 ** 10:
    minprice = 0

print(minprice)

Submission status: Accepted

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

min_xy=min(X,Y)
Max_xy=max(X,Y)
d=A*X+B*Y
e=C*2*Max_xy
if X>=Y:
    print(min(C*2*min_xy+(Max_xy-min_xy)*A,d,e))
else:
    print(min(C*2*min_xy+(Max_xy-min_xy)*B,d,e))

Submission status: Accepted

Solution code:
import sys
from functools import reduce
import copy
import math
from pprint import pprint


sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def int_inputs(num_of_input):
    ins = [int(input()) for i in range(num_of_input)]
    return ins


def solve(inputs):
    [A, B, C, x, y] = string_to_int(inputs[0])
    cost = 0
    if A + B > C * 2:
        while x >= 1 and y >= 1:
            cost += C * 2
            x -= 1
            y -= 1

    if A > C * 2:
        while x >= 1:
            cost += C * 2
            x -= 1
    else:
        while x >= 1:
            cost += A
            x -= 1

    if B > C * 2:
        while y >= 1:
            cost += C * 2
            y -= 1
    else:
        while y >= 1:
            cost += B
            y -= 1
    return cost


def string_to_int(string):
    return list(map(int, string.split()))


if __name__ == "__main__":
    ret = solve(inputs(1))
    print(ret)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
A,B,C,X,Y = [int(x) for x in input().split()]
mi = min(X,Y)
ans = 0
if mi*C*2<A*mi+B*mi:
  X = X-mi
  Y = Y-mi
  ans = mi*C*2
else:
  print(A*X+B*Y)
  exit()
if X>0:
  if X*C*2<X*A:
    ans += X*C*2
    print(ans)
    exit()
  else:
    ans += X*A
    print(ans)
    exit()
if Y>0:
  if Y*C*2<Y*B:
    ans += Y*C*2
    print(ans)
    exit()
  else:
    ans += Y*B
    print(ans)
    exit()
print(ans)

Submission status: Accepted

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

    prs = [a*x + b*y] # ストレートに購入
    # aを基準にc
    ac = x*2*c
    if y > x:
        z = y - x
        ac += min([b*z, z*2*c])
    prs.append(ac)

    # bを基準にc
    bc = y*2*c
    if x > y:
        z = x - y
        bc += min([a*z, z*2*c])
    prs.append(bc)

    print(min(prs))

cc095()

Submission status: Accepted

Solution code:
a,b,ab,a_c,b_c=map(int,input().split())
ans=[]
#そのまま
ans.append(a*a_c+b*b_c)
#合体（余りは捨てる）
ans.append(max(a_c,b_c)*ab*2)
#合体（足らない分は買う）
c=min(a_c,b_c)
ans.append(c*ab*2+(a_c-c)*a+(b_c-c)*b)
print(min(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 * y + c * 2 * (x-y))
  else:
    if b < 2 * c:
      print(c * 2 * x + b * (y-x))
    else:
      print(c * 2 * x + c * 2 * (y-x))

Submission status: Accepted

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

if X > Y:
    temp = X
    X = Y
    Y = temp
    temp = A
    A = B
    B = temp

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

ans = None
n1 = A*X + B*Y
if X > Y:
    n2 = C * 2*Y + A * (X - Y)
    n3 = C * 2*X
    ans = min(n1, n2, n3)
else:
    n2 = C * 2*X + B * (Y - X)
    n3 = C * 2*Y
    ans = min(n1, n2, n3)

print(ans)

Submission status: Accepted

Solution code:
def main():
    A, B, C, X, Y = (int(i) for i in input().split())
    ans1 = A * X + B * Y
    ans2 = 0
    ans3 = 0
    if X < Y:
        ans2 += 2 * C * X
        ans2 += B * (Y-X)
        ans3 += 2 * C * Y
    else:
        ans2 += 2 * C * Y
        ans2 += A * (X-Y)
        ans3 += 2 * C * X

    print(min(ans1,ans2,ans3))

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
A,B,C,X,Y = map(int,input().split())
cost = float("inf")
C_range = max(X,Y)*2
for i in range(C_range):
  cost = min(cost,i*2*C+max(0,X-i)*A+max(0,Y-i)*B)
print(cost)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def solve():
    a,b,c,x,y = map(int, input().split())
    z = [a*x + b*y, c*2*x + b*max(0,y-x), c*2*y + a*max(0,x-y), c*2*max(x,y)]
    return min(z)
        
if __name__ == '__main__':
    print(solve())

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
A,B,C,X,Y =map(int,input().split())
ans = 10**9
for c in range(max(2*X,2*Y)+1):
    ans = min(ans, A*max(0,math.ceil(X-c/2))+B*max(0,math.ceil(Y-c/2))+C*c)
print(ans)

Submission status: Accepted

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

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

print(min(P))

Submission status: Accepted

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

res = (
    c * max(x, y) * 2,
    a*x + b*y,
    c*x*2 + b*max(y-x, 0),
    c*y*2 + a*max(x-y, 0)
)

print(min(res))

Submission status: Accepted

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

ans = 10 ** 9
for i in range(0,max(X,Y)*2+1,2):
  p = i * C + A * max(X - i // 2, 0) + B * max(Y - i // 2, 0)
#  print (i,max(X - i // 2, 0),max(Y - i // 2, 0),p,ans)
  ans = min(ans, p)
print (ans)

Submission status: Accepted

Solution code:
a, b, c, x, y = map(int, input().split())
ans = 0
if a + b < c * 2:
    ans = x * a + y * b
else:
    if x <= y:
        # 余計にできる場合も考える
        ans = min(2 * c * x + b * (y - x), 2 * c * y)
    else:
        ans = min(2 * c * y + a * (x - y), 2 * c * x)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

ans1 = min(x,y) * min(a + b,c*2) + abs(x-y) * z
ans2 = c * max(x,y) * 2
print(min(ans1,ans2))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

answer = 10**18
n = 2*10**6+1
for c in range(n):
  a = X-c
  b = Y-c
  cost = C*c*2
  cost += max(a, 0)*A
  cost += max(b, 0)*B
  if answer > cost:
    answer = cost
print(answer)

Submission status: Accepted

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

answer = 10**18
for c in range(10**6+1):
  a = X-c
  b = Y-c
  cost = C*c*2
  cost += max(a, 0)*A
  cost += max(b, 0)*B
  if answer > cost:
    answer = cost
print(answer)

Submission status: Accepted

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

ab=c*2
n=max(x, y)+1
res=1145141919
for i in range(n):
    res=min(res, i*ab+max(0,x-i)*a+max(0,y-i)*b)
print(res)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a, b, c, x, y = map(int, input().split())
p0 = a * x + b * y
p1 = 2 * c * max(x, y)
a0 = 2 * c * min(x, y) + a * (max(x, y) - min(x, y))
b0 = 2 * c * min(x, y) + b * (max(x, y) - min(x, y))

if x <= y:
    print(min(p0, p1, b0))
else:
    print(min(p0, p1, a0))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b,c,x,y= map(int ,input().split())
h=max(x,y)
k=min(x,y)
j=h-k
if a+b>(c*2):
        i=k*(c*2)
        if h==x:
                l=j*2*c
                print(min(l,(j*a))+i)
        else:
                l=j*2*c
                print(min(l,(j*b))+i)     
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:
        print(a*x + b*y)
elif a+b > 2*c:
        if x == y:
                print(c * 2*x)
        elif x < y:
                print(min(c*2*x + b*(y-x), c*2*y))
        else:
                print(min(c*2*y + a*(x-y), c*2*x))

Submission status: Accepted

Solution code:




def main():

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

    if X == Y:
        price = min(cSet*X, A*X+B*Y)
    elif X > Y:
        price = min(cSet*X, cSet*Y+A*(X-Y), A*X+B*Y)
    else:
        price = min(cSet*Y, cSet*X+B*(Y-X), A*X+B*Y)
    
    print(price)



 





if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor


INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LIM(): return list(map(lambda x:int(x) - 1, sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def LIRM(n): return [LIM() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
mod = 1000000007


a, b, c, x, y = LI()
a = min(2 * c, a)
b = min(2 * c, b)

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

Submission status: Accepted

Solution code:
# ABC95 C -Half and Half
a,b,c,x,y = map(float,input().split())
ans = 0
if a+b > 2*c:
    while x != 0.0 and y != 0.0:
        ans += 2*c
        x -= 1.0
        y -= 1.0
        if y == 0.0:
            while x != 0.0:
                if a > 2*c:
                    ans += 2*c
                    x -= 1.0
                else:
                    ans += a
                    x -= 1.0
        if x == 0.0:
            while y != 0.0:
                if b > 2*c:
                    ans += 2*c
                    y -= 1.0
                else:
                    ans += b
                    y -= 1.0
else:
    ans += a*x + b*y
print(int(ans))

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(max(X, Y)):
    if x > 0 and y > 0:
        d = A + B - C * 2
    elif x <= 0:
        d = B - C * 2
    elif y <= 0:
        d = A - C * 2

    price = min(price, price - d)
    x -= 1
    y -= 1

print(price)

Submission status: Accepted

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

candidates = []
candidates.append(a * x + b * y)
candidates.append(c * max(x, y) * 2)
candidates.append(c * min(x, y) * 2 + (a if x > y else b) * abs(x - y))

print(min(candidates))

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

Submission status: Accepted

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


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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def solve():
    A,B,C,X,Y = map(int, input().split())
    ret = 0
    max_pizza = max(X,Y)
    min_pizza = min(X,Y)
    if A+B >= 2*C:
        ret += min_pizza*2*C
    else:
        ret += min_pizza*(A+B)
        
    max_price = B if X < Y else A
    if max_price <= 2*C:
        ret += (max_pizza - min_pizza)*max_price
    else:
        ret += 2*C*(max_pizza - min_pizza)
    
    print(ret)
    
solve()

Submission status: Accepted

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

    x1 = min(X, Y)
    price = min((A+B) * x1, 2 * C * x1)
    x2 = max(X, Y) - x1
    a = A if X > Y else B
    price += min(a * x2, 2 * C * x2)
    print(price)
solve()

Submission status: Accepted

Solution code:
def check():
    A, B, C, X, Y = [int(i) for i in input().split(' ')]
    if X > 0 and Y > 0:
        if 2*C < A+B:
            if X > Y:
                total = Y*2*C
                price = min(A, 2*C)
                total += (X-Y)*price
            else:
                total = X*2*C
                price = min(B, 2*C)
                total += (Y-X)*price
        else:
            total = A*X + B*Y
    elif X == 0:
        price = min(B, 2*C)
        total = price*Y
    else:
        price = min(A, 2*C)
        total = price*X
        
    print(total)
check()

Submission status: Accepted

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

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

Submission status: Accepted

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

n = max(int((x + 2 * c - 1) / (2 * c)),
        int((y + 2 * c - 1) / (2 * c)))
ret = float('inf')
for c_i in range(2 * (10 ** 5) + 1):
    a_i = max(x - c_i, 0)
    b_i = max(y - c_i, 0)
    cost = a_i * a + b_i * b + 2 * c_i * c
    ret = min(ret, cost)
print(ret)

Submission status: Accepted

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

# A ピザ p 枚、 B ピザ q 枚、 C ピザ r 枚　（c は偶数）
# p + r // 2 >= X
# q + r // 2 >= Y
# A * p + B * q + C * r を最小にする

# r を基準にしてループを回す

max_r = max(X, Y) * 2 

cost = float('inf')

for r in range(0, max_r+2, 2):
  p = max(X - r // 2, 0)
  q = max(Y - r // 2, 0)
  tmp_cost = A * p + B * q + C * r  
  cost = min(cost, tmp_cost)
  
print(cost)

Submission status: Accepted

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

ans = float("inf")

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

print(ans)

Submission status: Accepted

Solution code:
def main():
    A, B, AB, x, y = map(int, input().split())
    ans = []
    ans.append(A*x + B*y)
    if x < y:
        ans.append(AB*x*2 + B*(y-x))
        ans.append(AB*y*2)
    elif y < x:
        ans.append(AB*y*2 + A*(x-y))
        ans.append(AB*x*2)
    else:
        ans.append(AB*x*2)
    print(min(ans))


if __name__ == "__main__":
    main()