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())
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 = map(int, input().split())

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

print(ans)

Submission status: Accepted

Solution code:
(a, b, c, wanted_a, wanted_b) = (int(tok) for tok in input().split())

res = wanted_a * a + wanted_b * b
for both in range(max(wanted_a, wanted_b) * 2 + 1):
  left_a = wanted_a - both // 2
  left_b = wanted_b - both // 2
  cost = both * c + max(0, left_a) * a + max(0, left_b) * b
  res = min(res, cost)

print(res)

Submission status: Accepted

Solution code:
import sys

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

if A+B <= 2*C:
	print(A*X + B*Y)
	sys.exit()

else:
	ans = 0
	temp = min(X,Y)
	ans = 2*C*temp
	X -= temp
	Y -= temp

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

	print(ans)

Submission status: Accepted

Solution code:
import sys

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#### import ####
import sys
import math
from collections import defaultdict

#### 設定 ####
sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

#### 定数 ####
mod = 10**9 + 7

#### 読み込み ####
def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
    read_all = [tuple(map(int, input().split())) for _ in range(N)]
    return map(list,zip(*read_all))

#################

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)
##############################

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

ans = float('inf')
for i in range(max(x, y)+1 ):
    price = i * 2 * ab + max(0, x-i)*a + max(0, y-i)*b
    ans = min(ans, price)

print(ans)

Submission status: Accepted

Solution code:
a,b,c,x,y = map(int,input().split())
if x < y:
    big = b
    dd = y-x
else:
    big = a
    dd = x-y


sol_1 = a*x + b*y
sol_2 = c*min(x,y)*2 + big*dd
sol_3 = c*max(x,y)*2
print(min(sol_1,sol_2,sol_3))

Submission status: Accepted

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

ans=0
ans+=min(x,y)*min(a+b,2*c)
x,y=x-min(x,y),y-min(x,y)

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

print(ans)

Submission status: Accepted

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


if __name__ == "__main__":
    resolve()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
A, B, C, X, Y = [int(_) for _ in input().split()]
C*=2

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

ans += min(B * Y, Y * C)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    A, B, C, X, Y = map(int, input().split())
    AB = A+B
    cost = 0
    if 2*C <= AB:
        if X <= Y:
            return X * 2 * C + (Y-X) * min(2*C, B)
        else:
            return Y * 2 * C + (X-Y) * min(2*C, A)
    else:
        return X * A + Y * B

if __name__ == '__main__':
    print(main())

Submission status: Accepted

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

    #まずはA,Bどちらかが0になるまで購入
    fee+=min(x,y)*min(a+b,2*c)
    x, y=x-min(x,y), y-min(x,y)

    #残りのAを購入
    fee+=x*min(a, 2*c)

    #残りのBを購入
    fee+=y*min(b, 2*c)

    return fee
    
print(makeAccount())

Submission status: Accepted

Solution code:

a, b, c, x, y = [ int(v) for v in input().split() ]
ans = 10**10
for i in range(max(x,y)*2+2):
    x_i, y_i = x - i // 2, y - i // 2
    if x_i < 0:
        x_i = 0
    if y_i < 0:
        y_i = 0
    total = x_i * a + y_i * b + c * i
    ans = min(ans,total)

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

z = max(x,y) * 2
min_sum = c * z

for i in range(z):
    r = max(0, y - i) * b
    t = max(0, x - i) * a
    sum = c * i * 2 + r + t
    if sum < min_sum:
        min_sum = sum

print(min_sum)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# ABC 95, c
A, B, C, X, Y = [int(el) for el in input().split(' ')]
min_total = 10**9
for c in range(max(X, Y) * 2, -1, -2):
    a = max(X - c // 2, 0)
    b = max(Y - c // 2, 0)
    min_total = min(A*a + B*b + C*c, min_total)
print(min_total)

Submission status: Accepted

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

Submission status: Accepted

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

ans = a * x + b * y

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

Submission status: Accepted

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

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

Submission status: Accepted

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

ans = 10000000000
for i in range(2 * max(X, Y) + 1):
    A_half = i
    B_half = i
    cur_cost = i * C
    
    left_A_half = 2 * X - A_half
    left_B_half = 2 * Y - B_half
    if left_A_half > 0 :
        if left_A_half % 2 == 0:
            cur_cost += left_A_half // 2 * A
        else:
            cur_cost += (left_A_half // 2 + 1) * A
    
    if left_B_half >= 0:
        if left_B_half % 2 == 0:
            cur_cost += left_B_half // 2 * B
        else:
            cur_cost += (left_B_half // 2 + 1) * B
    
    ans = min(ans, cur_cost)
    
print(ans)

Submission status: Accepted

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

if X<Y:
    if B<2*C:
        total+=(Y-X)*B
    else:
        total+=(Y-X)*C*2

if X>Y:
    if A<2*C:
        total+=(X-Y)*A
    else:
        total+=(X-Y)*C*2

print(total)

Submission status: Accepted

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

maxxy = max([x,y])
price = 0

prices=[]

for i in range(maxxy+1):
  amai = x-i
  bmai = y-i
  
  if amai<0:
    amai = 0
  if bmai<0:
    bmai = 0
  
  price = i*2*c + amai*a + bmai*b
  prices.append(price)
  
print(min(prices))

Submission status: Accepted

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

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



main()

Submission status: Accepted

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

ab = min(x, y)
c2 = c * 2
p = 0

if a + b >= c2:
  x -= ab
  y -= ab
  p += c2 * ab

if a >= c2:
  p += c2 * x
  x = 0
  y -= x

if b >= c2:
  p += c2 * y
  y = 0
  x -= y

if x > 0:
  p += a * x

if y > 0:
  p += b * y
  
print(p)

Submission status: Accepted

Solution code:
A, B, AB, A_NUM, B_NUM = map(int, input().split())


if AB * 2 > A + B:
    print(A * A_NUM + B * B_NUM)
    exit()

ans = 0
nikoichi = min([A_NUM, B_NUM])
ans += AB * nikoichi * 2

if A_NUM > B_NUM:
    if A > AB * 2:
        ans += (A_NUM-B_NUM) * AB * 2
    else:
        ans += (A_NUM-B_NUM) * A
elif A_NUM < B_NUM:
    if B > AB * 2:
        ans += (B_NUM-A_NUM) * AB * 2
    else:
        ans += (B_NUM-A_NUM) * B

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

AandB = X * A + Y * B
allAB = max(X, Y) * 2 * C  # すべてAB

comb = min(X, Y) * 2 * C  # 余らないAB
minXY = min(X, Y)
X -= minXY
Y -= minXY
comb += X * A
comb += Y * B

print(min(AandB, allAB, comb))

Submission status: Accepted

Solution code:
A,B,C,X,Y = (int(i) for i in input().split())  
ans = 0
if C*2 <= A+B:
	for i in range(min(X,Y)):
		ans += C*2
		X-=1
		Y-=1
	ans += min(C*2, A)*X
	ans += min(C*2, B)*Y
else:
	ans += A*X
	ans += B*Y
print(ans)

Submission status: Accepted

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

x = 2*X
y = 2*Y
p = 0

if A+B >= 2*C:
    k = max(X,Y)-abs(X-Y)
    p += 2 * k * C
    X -= k
    Y -= k

while X>0:
    X -= 1
    if A > 2*C:
        p += 2*C
    else:
        p += A

while Y>0:
    Y -= 1
    if B > 2*C:
        p += 2*C
    else:
        p += B
        
print(p)

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:
    min_xy = min(x,y)
    max_xy = max(x,y)
    # ハーフハーフで少ない方を穴埋め
    n_c = min_xy*2
    v = n_c*c + max(0,x-min_xy)*a+max(0,y-min_xy)*b
    # print(min_xy,n_c,max(0,x-min_xy))
    # ハーフハーフで余らせた方が安い場合
    N_c = max_xy*2
    V = N_c * c
    print(min(v,V))

Submission status: Accepted

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

Submission status: Accepted

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

res = INF
for AB in range(max(X,Y)*2+1):
    x = AB*C
    a = AB//2
    b = AB//2
    if a < X:
        x += (X-a)*A
    if b < Y:
        x += (Y-b)*B
    if res > x:
        res = x
print(res)

Submission status: Accepted

Solution code:
a, b, c, x, y = list(map(int, input().split()))
nokori_x, nokori_y = x, y
cost = 0
count_a, count_b, count_c = 0, 0, 0

# まず、AとBのセットを最安の方法で買う
# AとBのセットは何個あるか？
ab_set_n = min(x, y)
if ab_set_n:
    if c * 2 < (a + b):
        # Cを買ったほうがお得
        cost += c * 2 * ab_set_n
    else:
        cost += (a + b) * ab_set_n

# セットにできるものはしたので、
# どちらもゼロ、あるいはAかBの片方だけが残っているはず
nokori_n = max(x, y) - ab_set_n
if nokori_n:
    price = a if max(x, y) == x else b
    if c * 2 < price:
        cost += c * 2 * nokori_n
    else:
        cost += price * nokori_n

print(cost)

Submission status: Accepted

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
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 I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  a,b,c,x,y=LI()
  return min(max(x,y)*c*2,a*x+b*y,max(0,x-y)*a+y*c*2,max(0,y-x)*b+x*c*2)

# main()
print(main())

Submission status: Accepted

Solution code:
A, B, ABhalf, X, Y = map(int, input().split())
ans_1 = max(X, Y) * 2 * ABhalf
ans_2 = 2 * Y * ABhalf + abs(X - Y) * A
ans_3 = 2*X*ABhalf+abs(X-Y)*B
ans_4 = X * A + Y * B
ans = min(ans_1, ans_2, ans_3, ans_4)
print(ans)

Submission status: Accepted

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

ans = 1e9
for c in range(max(X, Y)+1):
    a = max(X-c, 0)
    b = max(Y-c, 0)
    ans = min((A*a + B*b + 2*C*c), ans)

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:

def getint(): return int(input())
def getints(): return list(map(int, input().split()))

a,b,c,x,y=getints()

res = x*a + y*b
for c_count in range(0, max(x,y)*2 + 2, 2):
    x_need = max(0, x - c_count // 2)
    y_need = max(0, y - c_count // 2)
    tmp = x_need * a + y_need * b + c_count * c
    res = min(res, tmp)

print(res)

Submission status: Accepted

Solution code:
def getint(): return int(input())
def getints(): return list(map(int, input().split()))

a,b,c,x,y=getints()

res = 10 ** 10
for c_count in range(0, max(x,y)*2 + 2, 2):
    x_need = max(0, x - c_count // 2)
    y_need = max(0, y - c_count // 2)
    tmp = x_need * a + y_need * b + c_count * c
    res = min(res, tmp)

print(res)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys, math, fractions, itertools


def solve(A: int, B: int, C: int, X: int, Y: int):
    mn = 1e9
    for i in range(0, 2*(max(X, Y)+1), 2):
        mn = min(mn, C*i+A*max(X-i//2, 0)+B*max(Y-i//2, 0))
    print(int(mn))
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    X = int(next(tokens))  # type: int
    Y = int(next(tokens))  # type: int
    solve(A, B, C, X, Y)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:

a,b,c,x,y = map(int,input().split())
INF = 10**9
upp = max(x,y)*2
ans = INF

for i in range(upp+1):
    money = i*c
    half = i // 2
    if x > half:
        money += (x-half)*a
    if y > half:
        money += (y-half)*b
    if money < ans:
        ans = money
print(ans)

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

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
a,b,c,d,e=map(int,input().split());m=min;C=2*c;print((a*d+b*e,C*m(d,e)+(m(a,C)*(d-e),m(b,C)*(e-d))[e>d])[a+b>C])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

ans = a*x + b*y

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

ans1 = A*X + B*Y
ans2 = 0
ans3 = 0
if X >= Y:
  ans2 = A*(X-Y) + AB*Y*2
  ans3 = AB*X*2
else:
  ans2 = B*(Y-X) + AB*X*2
  ans3 = AB*Y*2
print(min(ans1, ans2, ans3))

Submission status: Accepted

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


def solve(A: int, B: int, C: int, X: int, Y: int):
    if(2*C >= A+B):
        print(A*X+B*Y)
        exit()

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

    print(ans)

    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    X = int(next(tokens))  # type: int
    Y = int(next(tokens))  # type: int
    solve(A, B, C, X, Y)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    s = S()
    s.append("o")
    a = s.count("o")-1
    print(700+a*100)
    return

#B
def B():
    n, x = LI()
    m = IR(n)
    m.sort()
    msum = sum(m)
    print(n + (x - msum) // m[0])
    return

#C
def C():
    a, b, c, x, y = LI()
    if c * 2 > a + b:
        print(x * a + y * b)
        return
    if x > y:
        if c * 2 > a:
            print(c * 2 * y + (x - y) * a)
            return
        print(c * 2 * x)
        return
    if c * 2 > b:
        print(c * 2 * x + (y - x) * b)
        return
    print(c * 2 * y)

    return

#D
def D():
    return

#Solve
if __name__ == '__main__':
    C()

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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


Set = min(X, Y)

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

print(ans)

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:

import math 

repo = list(map(int, input().split()))

a_kane = repo[0]
b_kane = repo[1]
c_kane = repo[2]
a_maisu = repo[3]
b_maisu = repo[4]
kingaku = 0

test_kane_tantai = 0
test_kane_harf = 0

tantai_kane = a_kane + b_kane
harf_kane = c_kane*2

kaburi_maisu = abs(a_maisu-b_maisu)


if(tantai_kane<harf_kane): #A,Bでシンプルに買った方がいい
    kingaku = a_kane*a_maisu + b_kane*b_maisu
else: #Cで買った方がいい
    if(a_maisu>b_maisu):
        sabun_maisu = a_maisu-b_maisu
        kaburi_maisu = b_maisu
        kingaku += kaburi_maisu*c_kane*2
        test_kane_tantai = sabun_maisu*a_kane
        test_kane_harf = sabun_maisu*c_kane*2
        if(test_kane_tantai>test_kane_harf):
            kingaku += test_kane_harf
        else:
            kingaku += test_kane_tantai
    else:
        sabun_maisu = b_maisu-a_maisu
        kaburi_maisu = a_maisu
        kingaku += kaburi_maisu*c_kane*2
        test_kane_tantai = sabun_maisu*b_kane
        test_kane_harf = sabun_maisu*c_kane*2
        if(test_kane_tantai>test_kane_harf):
            kingaku += test_kane_harf
        else:
            kingaku += test_kane_tantai

print(kingaku)

Submission status: Accepted

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

ansa=0
ansb=0
ansc=0

f=0
ff=0

if c*2 < a+b:
    #print("c安い")
    ansc=min(x,y)
    f=1
else:
    #print("c高い")
    ansa=x
    ansb=y

if f:
    #print(ansa, ansb, ansc)
    #print(c*2, a, x-ansc, b,  y-ansc, ansc)
    if c*2<a and x-ansc > 0:
        ansc+=x-ansc
        ff=1
        #print("aa")
    if c*2<b and y-ansc >0:
        ansc+=y-ansc
        ff=1
        #print("bb")
    if ff==0:
        ansa+=x-ansc
        ansb+=y-ansc
    

#print(ansa, ansb, ansc)
print(a*ansa + b*ansb + c*ansc*2)

Submission status: Accepted

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

#すべて単品, min(X,Y)をABで賄い不足を単品, すべてAB(超過は問題ない)
total=[0,0,0]
#case1
total[0]=A*X+B*Y
#case2
if X>=Y:
    cost=A
else:
    cost=B
total[1]=min(X,Y)*2*C+(max(X,Y)-min(X,Y))*cost
#case3
total[2]=max(X,Y)*2*C

print(min(total))

Submission status: Accepted

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

kakaku = [[A, 'a'], [B, 'b'], [C, 'c']]
buff = [[X, 0], [Y, 1]]
huta = A+B

ab = C*2

if ab > huta:
    print(A*X+B*Y)
    exit()
else:
    buff.sort()
    # print(buff)
    ans = buff[0][0]*ab
    diff = buff[1][0]-buff[0][0]
    # print(kakaku)
    # print(buff)
    # print(buff[0][1])
    mn = kakaku[buff[1][1]][0]
    # print(mn)
    if mn > ab:
        print(ans+(diff*ab))
        # print('kotti')
        exit()
    else:
        print(ans+(diff*mn))
        exit()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

#+++++
	



def main():
	a,b,c,x,y = map(int, input().split())
	
	get_price=lambda na,nb,nab:max(na,0) * a + max(nb,0) * b + max(nab,0) * c
	us=lambda x:max(0,x)
	
	r_min=get_price(x,y,0)
	#print(r_min)
	for i in range(max(x,y)+1):
		r=get_price(us(x - i), us(y - i), 2*i)
		r_min=r if r<r_min else r_min
		#print(r, '_',r_min)
	
	print(r_min)
	
	
#+++++

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
	else:
		input = sys.stdin.readline
		
	ret = main()
	if ret is not None:
		print(ret)
		
	if sys.platform =='ios':
		sys.stdin.close()

Submission status: Accepted

Solution code:
import math
import fractions
import copy
import numpy as np
def j(q):
    if q==1: print("Yes")
    elif q == 0:print("No")
    exit(0)
rem = pow(10,9)+7
"""
def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")
"""

def ip():
    return int(input())
def iprow():
    return [int(i) for i in input().split()]
def ips():
    return (int(i) for i in input().split())
def printrow(a):
    for i in a:
        print(i)
"""
#decomment when needed
def combinations(n,r):
    if n<r:return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def permutations(n,r):
    if n<r:return 0
    return math.factorial(n) // math.factorial(n - r)
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)
"""
a,b,c,x,y = ips()
c*=2
z = 0
sum = x*a+b*y
cm = sum
while x and y:
    x-=1
    y-=1
    z+=1
    sum-=(a+b)
    sum+=c
    cm = min(cm,sum)
if x:
    while x>0:
        x-=1
        sum-=a
        sum+=c
        cm = min(cm,sum)
elif y:
    while y>0:
        y -= 1
        sum -= b
        sum += c
        cm = min(cm, sum)
print(cm)

Submission status: Accepted

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

Submission status: Accepted

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