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

ans = [0,0,0]
ans[0] = a*x + b*y
ans[1] = max(x,y)*2*c

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

Submission status: Accepted

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

l = a * x + b * y
m = c * max(x, y) * 2

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

ans = min(l, min(m, n))
print(ans)

Submission status: Accepted

Solution code:
A, B, C, X, Y = map(int, input().split())
"""
Cを2k枚買う
"""

ans = 10 ** 10
k = 0
while True:
    money = C * k
    money += A * max(0, X - k // 2) + B * max(0, Y - k // 2)
    # print(max(0, X - k // 2), max(0, Y - k // 2), k, money)
    ans = min(ans, money)
    if k // 2 >= max(X, Y):
        break
    k += 2
print(ans)

Submission status: Accepted

Solution code:
# C - Half and Half

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

# 条件を満たすときのA, B, ABの買い方を全列挙したい
# A, Bの枚数は、ABの値が決まれば、一意に定まるため、
# ABのみループする。

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

Submission status: Accepted

Solution code:
# C - Half and Half

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

ans = 100000000000
if X > Y:
    for n_a in range(X+1):
        n_c = 2 * (X - n_a)
        n_b = Y - (n_c // 2)
        if n_b < 0:
            n_b = 0
        temp = A * n_a + B * n_b + C * n_c
        if ans > temp:
            ans = temp
    print(ans)
    exit()
else:
    for n_b in range(Y+1):
        n_c = 2 * (Y - n_b)
        n_a = X - n_c // 2
        if n_a < 0:
            n_a = 0
        temp = A * n_a + B * n_b + C * n_c
        if ans > temp:
            ans = temp
    print(ans)
    exit()

Submission status: Accepted

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

base = a * x + b * y

if x < y:
    t = y
else:
    t = x
    
for i in range(t+1):
    money = a * max(0, x - i) + b * max(0, y - i) + 2 * c * i 
    if money < base:
        base = money

print(base)

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0

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

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

def main():
    A, B, C, X, Y = map(int, open(0).read().split())
    
    S = []
    for i in range(0, 2*max(X, Y)+1):
        S.append(A*max(0, X - i//2) + B*max(0, Y - i//2) + C*i)
    print(min(S))

main()

Submission status: Accepted

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

#Cについての全列挙する
v1 = max(x*2,y*2)*c
v2 = a*x+b*y
v3=120000*100000
for i in range(max(x,y)+1):
    c_sum = c*2*(i)
    if x > i:
        c_sum += a*(x-i)
    if y > i:
        c_sum += b*(y-i)
    if c_sum < v3:
        v3 = c_sum
    # print(c_sum)

 # print(v1,v2,v3)
print(min(v1,v2,v3))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# https://atcoder.jp/contests/abc095/tasks/arc096

# 値段,枚数
A, B, C, X, Y = map(int, input().split())

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

print(ans)

Submission status: Accepted

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

#a,bピザをx,y用意する
#シンプルに用意する場合a*x+b*y
#abピザがa+bより安い場合代替する

ans1 = c*2*(max(x,y))
ans2 = a*x+b*y
ans3 = c*2*y+max((x-y),0)*a
ans4 = c*2*x+max((y-x),0)*b

print(min(ans1,ans2,ans3,ans4))

Submission status: Accepted

Solution code:
# https://atcoder.jp/contests/abc095/tasks/arc096

# 値段,枚数
A, B, C, X, Y = map(int, input().split())

# C * 2 は　A + Bとなる
ans = max(X, Y) * 2 * C

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

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

print(ans)

Submission status: Accepted

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

ans = 10**18

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

Submission status: Accepted

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

value = a+b
values = c*2

ans = 0

if value <= values:
    ans += a*x + b*y
    print(ans)
    exit()

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

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

Submission status: Accepted

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

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

print(Sum)

Submission status: Accepted

Solution code:
import sys
a, b, c, x, y = map(int, input().split())
ans=sys.maxsize
for i in range(max(x,y)+1):
  temp=2*c*i
  if x-i>0:
    temp+=a*(x-i)
  if y-i>0:
    temp+=b*(y-i)
  ans=min(ans,temp)

print(ans)

Submission status: Accepted

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

v1 = (C * 2) * max(X, Y)
v2 = (C * 2) * min(X, Y)
if X > Y:
    v2 += (X - Y) * A
else:
    v2 += (Y - X) * B
v3 = (A * X) + (B * Y)

print(min(v1, v2, v3))

Submission status: Accepted

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

if A+B > 2*C:
    m = C*min(X, Y)*2
    if X >= Y:
        rem = X-Y
        tmp = min(A*rem, C*2*rem)
    else:
        rem = Y-X
        tmp = min(B*rem, C*2*rem)
    print(m+tmp)
else:
    AX = A * X
    BY = B * Y
    print(AX+BY)

Submission status: Accepted

Solution code:
a, b, c, x, y = map(int, input().split())
ans1 = a * x + b * y  #そのまま
ans2 = 0
if x > y:  #少ない方をABで補う
    ans2 = c * min(x, y) * 2 + a * (x - y)
else:
    ans2 = c * min(x, y) * 2 + b * (y - x)
ans3 = c * max(x, y) * 2  #すべてABで
print(min(ans1, ans2, ans3))

Submission status: Accepted

Solution code:
a,b,c,x,y=map(int,input().split())
ans=1e10
for i in range(0,2*max(x,y)+1,2):
  d=c*i+max(0,x-i//2)*a+max(0,y-i//2)*b
  ans=min(d,ans)
print(ans)

Submission status: Accepted

Solution code:
A, B, C, X, Y = map(int, input().split())
value = float('inf')
D = max(X,Y)
for i in range(D+1):
  E = max((X-i)*A, 0)
  F = max((Y-i)*B, 0)
  valueX = 2*i*C+E+F
  if valueX < value:
    value  = valueX
print(str(value))

Submission status: Accepted

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

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

# Aピザを購入する
lower_price = 0

# 0 - X枚まで
for i in range(0, X + 1, 1):
    # Aピザ i枚と、Cピザ 2(X-i)枚を購入する
    price_a = A * i + C * 2 * (X - i)
    price_b = 0
    # Bピザの枚数が多い場合、不足分Bピザを購入する
    if X - i < Y:
        price_b = B * (Y - (X - i))
    price = price_a + price_b
    if lower_price == 0 or price < lower_price:
        lower_price = price

print(lower_price)

Submission status: Accepted

Solution code:
import numpy as np
def f(a, b, c, x, y):
    Min = np.inf
    for use_c in range(max(x, y) * 2 + 1):
        price = use_c * c + max(0, x - use_c // 2) * a + max(0, y - use_c // 2) * b
        if price < Min:
            Min = price
    print(Min)

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

Submission status: Accepted

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

ab = max(x, y) * 2 * c
a_b = a * x + b * y
if x >= y:
    ab_a_b = y*2*c + (x-y)*a
else:
    ab_a_b = x*2*c + (y-x)*b

print(min(ab, a_b, ab_a_b))

Submission status: Accepted

Solution code:


# if __name__ == "__main__":
#   A, B, C, X, Y = [int(item) for item in input().split()]
  
#   min_cost = None
#   for Na in range(0, X+1):
#     for Nb in range(0, Y+1):
#       Nc = max(X - Na, Y - Nb) * 2
      
#       cost = Na*A + Nb*B + Nc*C
#       if not min_cost:
#         min_cost = Na*A + Nb*B + Nc*C
#       else:
#         min_cost = min(cost, min_cost)
      
#   print(min_cost)
  
if __name__ == "__main__":
  A, B, C, X, Y = [int(item) for item in input().split()]

  min_cost = None
  for Nc in range(0, max(X, Y)*2+1):
    Na = max(0, X - Nc//2)
    Nb = max(0, Y - Nc//2)
    
    # print(Na, Nb, Nc)
    cost = Na*A + Nb*B + Nc*C
    if not min_cost:
      min_cost = Na*A + Nb*B + Nc*C
    else:
      min_cost = min(cost, min_cost)

  print(min_cost)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A,B,C,X,Y = map(int,input().split())
achete_A = 0
achete_B = 0
price = 0
C = 2 * C #=A,B
while achete_A < X and achete_B < Y:
    if A+B <= C:
        achete_A += 1
        achete_B += 1
        price += (A+B)
    else:
        achete_A += 1
        achete_B += 1
        price += C
if achete_A < X :
    while achete_A < X:
        if A < C:
            achete_A += 1
            price += A
        else:
            achete_A += 1
            price += C
elif achete_B < Y:
    while achete_B < Y:
        if B < C:
            achete_B += 1
            price += B
        else:
            achete_B += 1
            price += C
print(price)

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(0, max(2*x + 1, 2*y + 1), 2):
    price_new = int(max(a * (x - i/2), 0) + max(b * (y - i/2), 0) + c * i)
    if price > price_new:
        price = price_new
print(price)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
a, b, c, x, y = map(int, input().split())

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

Submission status: Accepted

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

A = []

A.append(a * x + b * y)

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

print(min(A))

Submission status: Accepted

Solution code:
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop

import collections

a,b,c,x,y = map(int,input().split())
"""
AとBのみ
"""
cost = x*a + y*b
"""
ABと個数あわせ
"""
cost2 = c*2*min(x,y)
if x>y:
    cost2 += (x-y)*a
else:
    cost2 += (y-x)*b
"""
ABのみ
"""
cost3 = c*2*max(x,y)
ans = min(cost,cost2)
ans = min(ans,cost3)
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
pa, pb, pab, na, nb = map(int, input().split())

'''
1. そのまま
2. 少ない方全てをabで

3. abいっぱいで余らせる
'''

ans1 = pa * na + pb * nb
ans2 = pab * min(na, nb) * 2 + (pa if(na > nb) else pb) * abs(na - nb)
ans3 = pab * max(na, nb) * 2

print(min(ans1, ans2, ans3))

Submission status: Accepted

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

#print( A,B,C,X,Y )

min_val = 0

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

print(min_val)

Submission status: Accepted

Solution code:
A, B, C, X, Y = map(int, input().split())
ans = 1 << 30
# ABピザを全探索して考える
for i in range(0, max(2*X,2*Y)+1, 2):
    x = X - i // 2
    y = Y - i // 2
    ans = min(ans, A * max(0,x) + B * max(0,y) + C * i)

print(ans)

Submission status: Accepted

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

# ABピザ以外で考えると
ans = A * X + B * Y

# ABピザを全探索して考える
for i in range(2, max(2*X,2*Y)+1, 2):
    x = X - i // 2
    y = Y - i // 2
    ans = min(ans, A * max(0,x) + B * max(0,y) + C * i)

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(100001):
    m = 2*c*i + max([0,x-i])*a +max([0,y-i])*b
    if ans > m:
        ans = m
print(ans)

Submission status: Accepted

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

pizza = {X : A, Y : B}
ans = 0

for i in range(max(X, Y)):
    if i <= min(X, Y) - 1:
        ans += min(A + B, 2 * C)
    else:
        ans += min(pizza[max(X, Y)], 2 * C)

print(ans)

Submission status: Accepted

Solution code:

def main():
    A, B, C, X, Y = map(int, input().split())
    M1 = A*X + B*Y
    M2 = C*2*min(X, Y) + (Y >= X) * (Y - X) * B + (X > Y) * (X - Y) * A
    M3 = C*2*max(X, Y)
    ans = min(M1, M2, M3)
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

cmax=max(x,y)*2
zmin=(a+b)*10**5
for nc in range(0,cmax+1,2):
    na=max(x-nc//2,0)
    nb=max(y-nc//2,0)
    z=a*na+b*nb+c*nc
    zmin=min(zmin,z)
    
print(zmin)

Submission status: Accepted

Solution code:
# 単体ピザで埋めてからハーフピザを買うか、
# ハーフピザで埋めてから単体ピザを足すのが良いはず。

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

#ハーフ埋め
esth = C * min(X, Y) * 2
a -= min(X,Y)
b -= min(X,Y)
esth += A * a + B * b
est.append(esth)

#全ハーフ
a, b = X, Y
estah = C * max(X, Y) * 2
est.append(estah)

#全単品
a, b = X, Y
estfa = A * a + B * b
est.append(estfa)

print(min(est))

Submission status: Accepted

Solution code:
n = list(map(int,input().split()))
price = []

# 場合分けしていくのは大変そうだった
for i in range(max(n[3], n[4]) + 1):
    temp = 2 * i * n[2]
    if n[3] - i > 0:
        temp += (n[3] - i) * n[0]
    if n[4] - i > 0:
        temp += (n[4] - i) * n[1]

    # 十分に大きい数値を最初用意して，2値を比較し小さい方を変数に入れる方がいいかも
    price.append(temp)

print(min(price))

Submission status: Accepted

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

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

Submission status: Accepted

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

def main():
    a, b, c, x, y = map(int, input().split())
    ab = c * 2

    i = min(x, y)
    if ab < a + b:
        pay = ab * i
    else:
        pay = a * i + b * i
    x -= i
    y -= i

    if x != 0:
        if ab < a:
            pay += ab * x
        else:
            pay += a * x
    elif y != 0:
        if ab < b:
            pay += ab * y
        else:
            pay += b * y

    print(pay)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def main():
    A, B, C, X, Y = map(int, input().split())
    
    if A + B <= 2*C:
        print(A*X+B*Y)
    
    elif A + B > 2*C:
        cost = 0
        mi = min(X, Y)
        cost += 2*C*mi
        X -= mi
        Y -= mi
        
        if X > 0 and Y == 0:
            if A <= 2*C:
                cost += A*X
            else:
                cost += 2*C*X
        else:
            if B <= 2*C:
                cost += B*Y
            else:
                cost += 2*C*Y
        print(cost)
if __name__ == "__main__":
    main()

Submission status: Accepted

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

if X >= Y:
    x=X ; y=Y ; a=A ; b=B
else:
    x=Y ; y=X ; a=B ; b=A
    
if 2*c < a+b:
    ans += 2*c*y
    if x!=y:
        if 2*c < a:
            ans += 2*c*(x-y)
        else:
            ans += a*(x-y)
else:
    ans += a*x + b*y
    
print(ans)

Submission status: Accepted

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

    k = 0
    ans = A * X + B * Y
    while True:
        ans = min(
            ans,
            AB * k * 2 + max(0, X - k) * A + max(0, Y - k) * B
        )

        if k >= M: break
        k += 1

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
s=list(map(int,input().split()))
a=0
if s[0]+s[1]>=2*s[2]:
  b=min(s[3],s[4])
  a+=(b*s[2]*2)
  s[3]-=b
  s[4]-=b
  if s[3]==0:
    if s[1]>=2*s[2]:
      a+=2*s[2]*s[4]
    else:
      a+=s[1]*s[4]
  else:
    if s[0]>=2*s[2]:
      a+=2*s[2]*s[3]
    else:
      a+=s[0]*s[3]
else:
  if s[0]>=2*s[2]:
    a+=2*s[2]*s[3]
    a+=s[1]*s[4]
  else:
    if s[1]>=2*s[2]:
      a+=2*s[2]*s[4]
      a+=s[0]*s[3]
    else:
      a+=s[0]*s[3]
      a+=s[1]*s[4]
print(a)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
import numpy as np
import sys

input = sys.stdin.readline

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


ans = A*X+B*Y
acnt = X
bcnt = Y

for i in range(max(X,Y)):
    tmp = ans

    if acnt > 0:
        acnt-=1
        tmp -= A
    if bcnt > 0:
        bcnt-=1
        tmp -= B

    ans =min(ans, tmp + C*2)

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

ans = 10**18
for c in range(max(X, Y) * 2 + 1):
    x = max(0, X - c // 2)
    y = max(0, Y - c // 2)
    ans = min(ans, x * A + y * B + c * C)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
input=sys.stdin.readline
a,b,c,x,y=map(int,input().split())
money1=a*x+b*y
money2=min(x,y)*2*c+(x-min(x,y))*a+(y-min(x,y))*b
money3=max(x,y)*c*2
print(min(money1,money2,money3))

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
# sys.setrecursionlimit(10 ** 6)
# MOD = 10 ** 9 + 7
# INF = float("inf")


def main():
    a, b, c, x, y = map(int, input().split())
    case1 = a * x + b * y
    if x - y > 0:
        case2 = c * 2 * y + a * (x - y)
    else:
        case2 = c * 2 * y
    if y - x > 0:
        case3 = c * 2 * x + b * (y - x)
    else:
        case3 = c * 2 * x
    print(min(case1, case2, case3))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from heapq import heapify, heappop, heappush
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

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

ans = INF

ma = max(X, Y)
t = ma * C * 2
ans = A * X + B * Y
# print(ans, t)
# exit()
mi = min(X, Y)
mi_X = X - mi
mi_Y = Y - mi
tmp = mi_X * A + mi_Y * B + C * mi * 2
ans = min(ans, tmp, t)
print(ans)
exit()

# for i in range():
# print(ans)
for i in range(min(X, Y) + 1):
    tmp = A * (X - i) + B * (Y - i) + C * 2 * i
    print(tmp)
    ans = min(tmp, ans)
print(ans)




# i = 0
# new = 0
# while new < ans:
#     new = A * (X - i) + B * (Y - i) + C * 2 * i
#     ans = min(ans, new)
#     print(ans)
#     i += 1
# print(ans)
    # if new < ans:
    #     ans = new
    #     i += 1
    # else:
    #     print(ans)
    #     break

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def resolve():
    a, b, c, x, y = map(int, input().split())
    p1 = x*a + y*b
    minp = min(x, y)
    if x >= y:
        p2 = minp*2*c + (max(x, y)-minp)*a

    else:
        p2 = minp * 2 * c + (max(x, y) - minp) * b
    p3 = max(x, y) * 2 * c
    print(min(p1, p2, p3))

resolve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H):
    '''
    H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_matrix(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right

# https://atcoder.jp/contests/abc095/tasks/arc096_a
A, B, C, X, Y = read_ints()

# もし組み合わせて買ったほうがいいなら限界まで組み合わせて買う
buyed = min(X, Y)
c1 = min(A + B, 2 * C) * buyed
X -= buyed
Y -= buyed

if X:
    c2 = min(A, 2 * C) * X
elif Y:
    c2 = min(B, 2 * C) * Y
else:
    c2 = 0

print(c1 + c2)

Submission status: Accepted

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

if __name__ == '__main__':
    solve()

Submission status: Accepted

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

Submission status: Accepted

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

sum1 = a*x + b*y

num = min(x, y)
sum2 = num * 2 * c + a*(x-num) + b*(y-num)
sum3 = max(x,y) * 2 * c

print(min(sum1, sum2, sum3))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,sqrt,factorial,hypot,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint
def ceil(a,b): return (a+b-1)//b
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    A,B,C,X,Y = MI()
    C*=2
    ans = A*X+B*Y
    if(X>Y):
        ans = min(ans,min(X,Y)*C + (X-Y)*A)
    else:
        ans = min(ans,min(X,Y)*C + (Y-X)*B)
    ans = min(ans,max(X,Y)*C)
    print(ans)
if __name__ == '__main__':
    main()