AtCoder Beginner Contest 095 - Half and Half

"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-----
1500 2000 1600 3 2

-----Sample Output-----
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.

Difficulty: EASY

Starter code:

Solutions:
(A, B, C, X, Y) = map(int, input().split())
ab = min(2 * C, A + B)
a = min(2 * C, A)
b = min(2 * C, B)
if X <= Y:
	ans = X * ab + (Y - X) * b
else:
	ans = Y * ab + (X - Y) * a
print(ans)


(a, b, c, x, y) = map(int, input().split())
m = min(x, y)
M = max(x, y)
p = a * x + b * y
q = c * m * 2 + a * (x - m) + b * (y - m)
r = c * M * 2
print(min(p, q, r))


(a, b, c, x, y) = map(int, input().split())
ab = a * x + b * y
cc = c * 2 * max(x, y)
abcc = c * 2 * min(x, y) + (b if x < y else a) * abs(x - y)
print(min(ab, cc, abcc))


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


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


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


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


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


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


(A, B, C, X, Y) = map(int, input().split())
ans = 5000 * 1000000
for i in range(0, max(X, Y) * 2 + 1, 2):
	x = max(0, X - i // 2)
	y = max(0, Y - i // 2)
	ans = min(ans, A * x + B * y + C * i)
print(ans)


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


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


(a, b, c, x, y) = map(int, input().split())
d = a * x + b * y
e = 2 * c * x + b * max(0, y - x)
f = 2 * c * y + a * max(0, x - y)
print(min(d, e, f))


import sys
input = sys.stdin.readline

def main():
	(a, b, c, x, y) = map(int, input().split())
	ans1 = 99999999999999999999999999
	if a + b > 2 * c:
		if x > y:
			ans1 = 2 * c * y + a * (x - y)
		elif y > x:
			ans1 = 2 * c * x + b * (y - x)
	ans2 = c * 2 * max(x, y)
	ans3 = a * x + b * y
	print(min(ans1, ans2, ans3))

def __starting_point():
	main()
__starting_point()


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


(a, b, c, x, y) = map(int, input().split())
print(min((k * c * 2 + a * max(x - k, 0) + b * max(y - k, 0) for k in range(max(x, y) * 3))))


import math
(A, B, C, X, Y) = map(int, input().split())
ans = A * X + B * Y
if (A + B) / 2 < C:
	pass
else:
	for i in range(max(X * 2, Y * 2) + 1):
		j = max(0, X - int(i / 2))
		k = max(0, Y - int(i / 2))
		ans = min(ans, i * C + j * A + k * B)
print(ans)


(a_price, b_price, ab_price, num_a, num_b) = list(map(int, input().split()))
total = 0
if a_price + b_price < 2 * ab_price:
	total = a_price * num_a + b_price * num_b
elif a_price + b_price >= 2 * ab_price:
	if num_a >= num_b:
		if a_price > ab_price * 2:
			total = ab_price * 2 * num_a
		else:
			total = ab_price * 2 * num_b + a_price * (num_a - num_b)
	elif b_price > ab_price * 2:
		total = ab_price * 2 * num_b
	else:
		total = ab_price * 2 * num_a + b_price * (num_b - num_a)
print(total)


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


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


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


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


(a, b, c, x, y) = map(int, input().split())
ans1 = a * x + b * y
ans2 = 2 * c * max(x, y)
ans3 = 2 * c * min(x, y) + a * (x - min(x, y)) + b * (y - min(x, y))
print(min(ans1, ans2, ans3))


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


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


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


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


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


(a, b, c, x, y) = map(int, input().split())
answer = 7000000000
for i in range(100001):
	amount = i * 2 * c + max(0, x - i) * a + max(0, y - i) * b
	if answer > amount:
		answer = amount
print(answer)


(A, B, C, X, Y) = map(int, input().split())
moneys = []
for i in range(0, 2 * max(X, Y) + 1, 2):
	if X - i // 2 >= 0 and Y - i // 2 >= 0:
		moneys.append((X - i // 2) * A + (Y - i // 2) * B + C * i)
	elif X - i // 2 >= 0 and Y - i // 2 < 0:
		moneys.append((X - i // 2) * A + C * i)
	elif X - i // 2 < 0 and Y - i // 2 >= 0:
		moneys.append((Y - i // 2) * B + C * i)
	else:
		moneys.append(C * i)
print(min(moneys))


(a, b, c, x, y) = map(int, input().split())
n = a * x + b * y
m = 2 * c * max(x, y)
p = b if x < y else a
l = 2 * c * min(x, y) + p * abs(x - y)
ans = min(n, min(m, l))
print(ans)


(A, B, C, X, Y) = map(int, input().split())
a = A * X + B * Y
b = max(X, Y) * C * 2
p = B if X < Y else A
c = min(X, Y) * C * 2 + p * abs(X - Y)
print(min(a, b, c))


(A, B, C, X, Y) = map(int, input().split())
Z = min(X, Y)
W = max(X, Y)
a = X * A + Y * B
b = (X - Z) * A + (Y - Z) * B + 2 * Z * C
c = 2 * W * C
print(min(a, b, c))


(a, b, c, x, y) = list(map(int, input().split()))
sum = a + b
if x > y:
	cost = a
else:
	cost = b
if sum > 2 * c:
	if x == y:
		total = 2 * x * c
		pass
	else:
		total = 2 * min(x, y) * c
		num = max(x, y) - min(x, y)
		if cost * num < 2 * num * c:
			total += cost * num
		else:
			total += 2 * num * c
elif sum == 2 * c:
	if x == y:
		total = x * 2 * c
		pass
	else:
		total = min(x, y) * 2 * c
		num = max(x, y) - min(x, y)
		if cost * num < 2 * c * num:
			total += cost * num
		else:
			total += num * 2 * c
else:
	total = a * x + b * y
print(total)


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


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


(a, b, c, x, y) = [int(x) for x in input().split()]
res = 0
if a + b > 2 * c:
	res += min(x, y) * 2 * c
	if x == min(x, y):
		if b > 2 * c:
			res += (y - min(x, y)) * 2 * c
		else:
			res += (y - min(x, y)) * b
	elif a > 2 * c:
		res += (x - min(x, y)) * 2 * c
	else:
		res += (x - min(x, y)) * a
else:
	res += a * x
	res += b * y
print(res)


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


(A, B, C, X, Y) = list(map(int, input().split()))
ans = 10000000000
cost = 0
cost = max(X, Y) * C * 2
ans = min(ans, cost)
if X > Y:
	cost = Y * C * 2
	cost1 = cost + (X - Y) * A
	cost2 = cost + (X - Y) * C * 2
	cost = min(cost1, cost2)
	ans = min(ans, cost)
else:
	cost = X * C * 2
	cost1 = cost + (Y - X) * B
	cost2 = cost + (Y - X) * C * 2
	cost = min(cost1, cost2)
	ans = min(ans, cost)
cost = A * X + B * Y
ans = min(ans, cost)
print(ans)


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


(a, b, c, X, Y) = map(int, input().split())
s = min(X, Y)
t = max(X, Y)
ans1 = 2 * c * s + a * (X - s) + b * (Y - s)
ans2 = a * X + b * Y
ans3 = 2 * c * t
print(min(ans1, ans2, ans3))


def II():
	return int(input())

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

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

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

def __starting_point():
	main()
__starting_point()


(A, B, C, X, Y) = map(int, input().split())
ans = 10 ** 9
for c in range(max(X, Y) + 1):
	a = max(X - c, 0)
	b = max(Y - c, 0)
	cost = A * a + B * b + C * 2 * c
	ans = min(cost, ans)
print(ans)


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


(a, b, c, x, y) = map(int, input().split())
mast = max(x, y)
ans = float('INF')
for i in range(mast + 1):
	price = a * max(x - i, 0) + b * max(y - i, 0) + c * 2 * i
	ans = min(ans, price)
print(ans)


(A, B, C, X, Y) = map(int, input().split(' '))
price = []
for i in range(100001):
	price.append(2 * C * i + A * max([X - i, 0]) + B * max([Y - i, 0]))
print(min(price))


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


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


(A, B, C, X, Y) = list(map(int, input().split()))
ans1 = 2 * C * min(X, Y) + A * (X - min(X, Y)) + B * (Y - min(X, Y))
ans2 = A * X + B * Y
ans3 = 2 * C * max(X, Y)
ans = min(ans1, ans2, ans3)
print(ans)


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


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


def slove():
	(A, B, C, X, Y) = map(int, input().split())
	ans1 = A * X + B * Y
	if X < Y:
		ans2 = B * abs(X - Y) + C * 2 * min(X, Y)
	else:
		ans2 = A * abs(X - Y) + C * 2 * min(X, Y)
	ans3 = C * 2 * max(X, Y)
	print(min(ans1, ans2, ans3))

def __starting_point():
	slove()
__starting_point()


def mapt(fn, *args):
	return tuple(map(fn, *args))

def Input():
	return mapt(int, input().split(' '))

def main():
	(a, b, c, x, y) = Input()
	if a + b < c * 2:
		print(a * x + b * y)
		return
	if x == y:
		print(c * x * 2)
	elif x > y:
		temp = x - y
		print(min(2 * c * x, 2 * c * y + temp * a))
	else:
		temp = y - x
		print(min(2 * c * y, 2 * c * x + temp * b))
main()


(A, B, C, X, Y) = map(int, input().split())
dpr = min(A + B, 2 * C)
Apr = min(A, 2 * C)
Bpr = min(B, 2 * C)
dam = dpr * min(X, Y)
if X >= Y:
	sam = Apr * (X - Y)
else:
	sam = Bpr * (Y - X)
print(dam + sam)


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


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


(A, B, C, X, Y) = list(map(int, input().split()))
min_p = 100000000000000
for c in range(0, max(X, Y) * 2 + 1):
	a = X - int(c / 2)
	b = Y - int(c / 2)
	if a < 0:
		a = 0
	if b < 0:
		b = 0
	p = A * a + B * b + C * c
	min_p = min(min_p, p)
print(min_p)


(A, B, C, X, Y) = list(map(int, input().split()))
result = []
if X > Y:
	result.append(A * X + B * Y + C * 0)
	result.append(A * (X - Y) + B * 0 + C * 2 * min(X, Y))
	result.append(A * 0 + B * 0 + C * 2 * max(X, Y))
elif X < Y:
	result.append(A * X + B * Y + C * 0)
	result.append(A * 0 + B * (Y - X) + C * 2 * min(X, Y))
	result.append(A * 0 + B * 0 + C * 2 * max(X, Y))
else:
	result.append(A * X + B * Y + C * 0)
	result.append(A * 0 + B * 0 + C * 2 * max(X, Y))
print(min(result))


import sys
input = sys.stdin.readline
(a, b, c, x, y) = map(int, input().split())
ab = 2 * c
count_x = 0
count_y = 0
buy_a = 0
buy_b = 0
buy_c = 0
if ab < a + b:
	min_count = min(x, y)
	count_x = min_count
	count_y = min_count
	buy_c = 2 * min_count
	if x - count_x > 0:
		if ab > a:
			buy_a += x - count_x
		else:
			buy_c += 2 * (x - count_x)
	elif y - count_y > 0:
		if ab > b:
			buy_b += y - count_y
		else:
			buy_c += 2 * (y - count_y)
else:
	min_count = min(x, y)
	if min_count == x:
		buy_a = min_count
		if ab > b:
			buy_b += y
		else:
			buy_c += 2 * y
	else:
		buy_b = min_count
		if ab > a:
			buy_a += x
		else:
			buy_c += 2 * x
print(buy_a * a + buy_b * b + buy_c * c)


(a, b, c, x, y) = map(int, input().split())
print(min(a * x + b * y, c * 2 * max(x, y), c * 2 * min(x, y) + abs(x - y) * max([[x, a], [y, b]], key=lambda s: s[0])[1]))


(a, b, c, X, Y) = map(int, input().split())
min1 = 10 ** 10
for z in range(0, 200001, 2):
	x = max(0, X - z // 2)
	y = max(0, Y - z // 2)
	min1 = min(min1, a * x + b * y + c * z)
print(min1)


(A, B, C, X, Y) = map(int, input().split())
import math
saishou = math.inf
temp = 0
for i in range(0, X + 1):
	temp = A * i + C * 2 * (X - i)
	if X - i < Y:
		if 2 * C <= B:
			temp += 2 * C * (Y - (X - i))
		else:
			temp += B * (Y - (X - i))
	if saishou > temp:
		saishou = temp
print(saishou)


def LI():
	return list(map(int, input().split()))
(a, b, c, x, y) = LI()
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)


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

def f(x, y):
	return x - y if x > y else 0
print(min(2 * c * x + f(y, x) * b, 2 * c * y + f(x, y) * a, a * x + b * y))


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


import math
(A, B, C, X, Y) = list(map(int, input().split()))
min_sum = A * X + B * Y
for c in range(0, max(X, Y) * 2 + 1, 2):
	s = max(X - math.floor(c / 2), 0) * A + max(Y - math.floor(c / 2), 0) * B + c * C
	if s < min_sum:
		min_sum = s
print(min_sum)


(a, b, c, x, y) = map(int, input().split())
i = a * x + b * y
j = c * min(x, y) * 2 + a * (x - min(x, y)) + b * (y - min(x, y))
k = c * max(x, y) * 2
print(min(i, j, k))


(a, b, c, x, y) = list(map(int, input().split()))
c *= 2
t = 0
if a + b > c:
	v = min([x, y])
	t = v * c
	(x, y) = (x - v, y - v)
	if x > 0:
		if a < c:
			t = t + a * x
		else:
			t = t + c * x
	elif y > 0:
		if b < c:
			t = t + b * y
		else:
			t = t + c * y
else:
	t = a * x + b * y
print(t)


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


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


(A, B, C, X, Y) = map(int, input().split())
ans = float('INF')
for k in range(0, 2 * max(X, Y) + 1, 2):
	i = max(0, X - int(k / 2))
	j = max(0, Y - int(k / 2))
	ans = min(ans, A * i + B * j + C * k)
print(ans)


import math
(a, b, c, x, y) = list(map(int, input().split(' ')))
ans = float('inf')
c = c * 2
for i in range(max(x, y) + 1):
	ans = min(ans, a * max(0, x - i) + b * max(0, y - i) + c * i)
print(ans)


(A, B, C, X, Y) = map(int, input().split())
price = 0
m = min(A + B, C * 2)
n = min(X, Y)
price += m * n
d = max(X, Y) - min(X, Y)
if d != 0:
	if X > Y:
		price += min(A, C * 2) * d
	else:
		price += min(B, C * 2) * d
print(price)


(A, B, C, X, Y) = map(int, input().split())
ans = 10 ** 10
for k in range(max(X, Y) + 1):
	i = max(X - k, 0)
	j = max(Y - k, 0)
	price = A * i + B * j + C * 2 * k
	ans = min(ans, price)
print(ans)


3
(A, B, C, X, Y) = (int(x) for x in input().split())
ret = 0
if A + B > C * 2:
	m = min(X, Y)
	X -= m
	Y -= m
	ret += m * C * 2
if X > 0:
	if A > C * 2:
		ret += X * C * 2
	else:
		ret += X * A
if Y > 0:
	if B > C * 2:
		ret += Y * C * 2
	else:
		ret += Y * B
print(ret)


import sys

def readint():
	return int(sys.stdin.readline())

def readints():
	return tuple(map(int, sys.stdin.readline().split()))

def readintslist(n):
	return [tuple(map(int, sys.stdin.readline().split())) for _ in range(n)]

def main():
	(a, b, c, x, y) = readints()
	a_pizza = [a * i for i in range(x + 1)]
	b_pizza = [b * i for i in range(y + 1)]
	ab_pizza = [2 * c * i for i in range(max(x, y) + 1)]
	ans = []
	for i in range(max(x, y) + 1):
		ans.append(a_pizza[max(x - i, 0)] + b_pizza[max(y - i, 0)] + ab_pizza[i])
	print(min(ans))

def __starting_point():
	main()
__starting_point()


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


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


(A, B, C, X, Y) = map(int, input().split())
mi = min(X, Y)
a = A * X + B * Y
b = mi * C * 2 + A * (X - mi) + B * (Y - mi)
c = max(X, Y) * C * 2
print(min(a, b, c))


(a, b, c, x, y) = map(int, input().split())
piza_min = min(x, y)
plan1 = c * piza_min * 2 + a * (x - piza_min) + b * (y - piza_min)
plan2 = a * x + b * y
plan3 = c * max(x, y) * 2
print(min(plan1, plan2, plan3))


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


(a, b, c, x, y) = map(int, input().split())
z = min(x, y)
ans = min(a * z + b * z, c * z * 2) + min(a * (x - z), c * 2 * (x - z)) + min(b * (y - z), c * 2 * (y - z))
print(ans)


(A, B, C, X, Y) = list(map(int, input().split()))
ans = 10000 * 10 ** 5
for z in range(10 ** 5 + 1):
	x = max(X - z, 0)
	y = max(Y - z, 0)
	yen = A * x + B * y + 2 * C * z
	if ans > yen:
		ans = yen
print(ans)


(A, B, C, X, Y) = map(int, input().split())
ans = 2 * (5000 * 10 ** 5)
for Z in range(10 ** 5 + 1):
	total = A * max(X - Z, 0) + B * max(Y - Z, 0) + 2 * C * Z
	ans = min(total, ans)
print(ans)


(A, B, C, X, Y) = map(int, input().split())
pay1 = X * A + Y * B
pay2 = 10 ** 10
if Y >= X:
	pay2 = C * 2 * X + B * (Y - X)
pay3 = 10 ** 10
if X >= Y:
	pay3 = A * (X - Y) + C * 2 * Y
pay4 = C * max(X, Y) * 2
print(min(pay1, pay2, pay3, pay4))


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


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


(a, b, c, x, y) = map(int, input().split())
ans = float('inf')
for i in range(max(x, y) + 1):
	t = a * max(0, x - i) + b * max(0, y - i) + 2 * c * i
	ans = min(ans, t)
print(ans)


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


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


(a, b, c, x, y) = map(int, input().split())
ans = 0
ans += min(x, y) * min(2 * c, a + b)
s = max(0, x - y)
t = max(0, y - x)
ans += s * min(a, 2 * c)
ans += t * min(b, 2 * c)
print(ans)


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


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


(a, b, c, x, y) = list(map(int, input().split()))
mmin = -1

def maxint(x, y: int) -> int:
	if x > y:
		return x
	else:
		return y
max = maxint(x, y)
for i in range(0, max + 1):
	tmp = 2 * c * i + a * maxint(0, x - i) + b * maxint(0, y - i)
	if mmin == -1:
		mmin = tmp
		continue
	if tmp < mmin:
		mmin = tmp
print(mmin)


(a, b, c, x, y) = map(int, input().split())
ans = 0
ab = min(a + b, c * 2)
temp = min(x, y)
ans += ab * temp
x -= temp
y -= temp
ans += min(a, c * 2) * x
ans += min(b, c * 2) * y
print(ans)


(A, B, C, X, Y) = map(int, input().split())
dif = abs(X - Y)
rem = max(X, Y)
if rem == X:
	E = A
else:
	E = B
com = rem - dif
ans = 0
D = A + B
if D < C * 2:
	ans += D * com
else:
	ans += C * com * 2
if E < C * 2:
	ans += E * dif
else:
	ans += C * dif * 2
print(ans)


(a, b, c, x, y) = list(map(int, input().split()))
moneys = []
for i in range(0, max(x, y) * 2 + 1, 2):
	apizza = x - int(i / 2)
	bpizza = y - int(i / 2)
	if apizza < 0:
		apizza = 0
	if bpizza < 0:
		bpizza = 0
	money = apizza * a + bpizza * b + i * c
	moneys.append(money)
print(min(moneys))


(A, B, C, X, Y) = map(int, input().split())
p_A = A * X
p_B = B * Y
total = p_A + p_B
if X > Y:
	a = X - Y
	ab = Y * C * 2
	total_ab = C * X * 2
	total_1 = ab + a * A
	print(min(total_1, total, total_ab))
elif X < Y:
	b = Y - X
	ab = X * C * 2
	total_ab = C * Y * 2
	total_2 = ab + b * B
	print(min(total_2, total, total_ab))
elif X == Y:
	ab = C * X * 2
	print(min(ab, total))


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


(a, b, c, x, y) = map(int, input().split())
([m, n], [M, N]) = sorted([[x, a], [y, b]])
print(min(a * x + b * y, c * 2 * M, c * 2 * m + (M - m) * N))


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


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


(a, b, c, x, y) = map(int, input().split())
val = a * x + b * y
val2 = 2 * c * x + b * (y - x) if y > x else 2 * c * y + a * (x - y)
val3 = 2 * c * max(x, y)
print(min(val, val2, val3))


l = list(map(int, input().split()))
(A, B, C, X, Y) = (l[0], l[1], l[2], l[3], l[4])
(s_1, s_2, s_3) = (0, 0, 0)
s_1 = A * X + B * Y
maxv = max([X, Y])
s_2 = 2 * C * max([X, Y])
if X >= Y:
	s_3 = 2 * C * Y + A * (X - Y)
else:
	s_3 = 2 * C * X + B * (Y - X)
print(min([s_1, s_2, s_3]))


(a, b, c, x, y) = map(int, input().split())
ans = 10000000000.0
for k in range(100010):
	ans = min(2 * c * k + max(x - k, 0) * a + max(y - k, 0) * b, ans)
print(int(ans))


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


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


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


import math
(a, b, c, x, y) = map(int, input().split(' '))
ans = float('inf')
c = c * 2
for i in range(max(x, y) + 1):
	if i > x:
		price = b * (y - i) + c * i
	elif i > y:
		price = a * (x - i) + c * i
	else:
		price = a * (x - i) + b * (y - i) + c * i
	if ans > price:
		ans = price
print(ans)


def main():
	(A, B, C, X, Y) = list(map(int, input().split()))
	ans = 0
	min_p = min(X, Y)
	d = X - Y
	if A + B > 2 * C:
		ans += 2 * C * min_p
	else:
		ans += (A + B) * min_p
	if d > 0:
		if A > 2 * C:
			ans += 2 * C * d
		else:
			ans += A * d
	elif d < 0:
		if B > 2 * C:
			ans += 2 * C * -d
		else:
			ans += B * -d
	print(ans)

def __starting_point():
	main()
__starting_point()


(A, B, C, X, Y) = (int(i) for i in input().split())
A = min(A, 2 * C)
B = min(B, 2 * C)
AB = min(A + B, 2 * C)
print(AB * min(X, Y) + A * (X - min(X, Y)) + B * (Y - min(X, Y)))


(a, b, c, x, y) = list(map(int, input().split()))
mincost = a * x + b * y
for z in range(max(x, y) + 1):
	x_ = max(0, x - z)
	y_ = max(0, y - z)
	cost = 2 * c * z + a * x_ + b * y_
	mincost = min(mincost, cost)
print(mincost)


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


(a, b, c, x, y) = map(int, input().split())
c *= 2
d = a * x + b * y
f = max(x, y) * c
if x < y:
	e = x * c + (y - x) * b
else:
	z = x - y
	e = y * c + (x - y) * a
print(min(d, min(e, f)))


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


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


(a, b, c, x, y) = map(int, input().split())
normal = a * x + b * y
half = c * 2 * min(x, y) + max(a * (x - y), b * (y - x))
allhalf = c * 2 * max(x, y)
print(min(half, normal, allhalf))


(A, B, AB, X, Y) = map(int, input().split())
AB *= 2
result = [A * X + B * Y, AB * max(X, Y), AB * Y + A * (X - Y) if X > Y else AB * X + B * (Y - X)]
print(min(result))


(A, B, c, a, b) = map(int, input().split())
print(min(c * max(a, b) * 2, A * a + B * b, [A, B][a < b] * abs(a - b) + c * min(a, b) * 2))


(a, b, c, x, y) = map(int, input().split())
m = max(x, y)
ans = 10 ** 9 + 7
for e in range(m + 1):
	ans = min(ans, 2 * e * c + a * max(0, x - e) + b * max(0, y - e))
print(ans)


(A, B, C, X, Y) = map(int, input().split())
if 2 * C <= A + B:
	price = 2 * C
else:
	price = A + B
maxN = max(X, Y)
miniN = min(X, Y)
res = miniN * price
residue = maxN - miniN
if residue == 0:
	print(res)
elif X > Y:
	res += min(residue * A, residue * 2 * C)
	print(res)
elif Y > X:
	res += min(residue * B, residue * 2 * C)
	print(res)


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


(a, b, c, x, y) = map(int, input().split())
if x < y:
	(x, y) = (y, x)
	(a, b) = (b, a)
price_1 = a * x + b * y
price_2 = a * (x - y) + 2 * c * y
price_3 = 2 * c * x
print(min(price_1, price_2, price_3))


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


(A, B, C, X, Y) = map(int, input().split())
K = 10 ** 9
for i in range(10 ** 5 + 1):
	S = i * 2 * C + max(0, X - i) * A + max(0, Y - i) * B
	K = min(K, S)
print(K)


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


(A, B, C, X, Y) = map(int, input().split())
ans = 0
ans = A * X + B * Y
z = min(X, Y)
x = X - z
y = Y - z
ans = min(ans, x * A + y * B + C * 2 * z)
z = max(X, Y)
ans = min(ans, C * 2 * z)
print(ans)


(A, B, C, X, Y) = map(int, input().split())
min_xy = min(X, Y)
max_xy = max(X, Y)
ans1 = 2 * C * min_xy + A * (X - min_xy) + B * (Y - min_xy)
ans2 = A * X + B * Y
ans3 = 2 * C * max_xy
print(min(ans1, ans2, ans3))


(a, b, c, x, y) = map(int, input().split())
A_B = a * x + b * y
AB = 2 * c * max(x, y)
if x == y:
	C = c * 2 * x
elif x > y:
	C = c * 2 * y + a * (x - y)
else:
	C = c * 2 * x + b * (y - x)
print(min(A_B, AB, C))


(a, b, c, x, y) = list(map(int, input().split()))
if a + b <= 2 * c:
	print(a * x + b * y)
else:
	max_c = max(x, y)
	min_c = min(x, y)
	AB = 2 * c * max_c
	if x > y:
		SP = (x - min_c) * a + 2 * c * min_c
	else:
		SP = (y - min_c) * b + 2 * c * min_c
	print(min(AB, SP))


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


(A, B, C, X, Y) = list(map(int, input().split()))
ans = float('inf')
for c in range(200001):
	cost = c * C
	cost += A * max(0, X - c // 2)
	cost += B * max(0, Y - c // 2)
	ans = min(ans, cost)
print(ans)