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 = list(map(int, input().split()))
a, b, c = 0, 0, 0
if(A + B <= 2*C):
    a, b = X, Y
else:
    c = min(X, Y) * 2
    if(X > Y):
        if(A > 2*C):
            c += (X - Y) * 2
        else:
            a = (X - Y)
    else:
        if(B > 2*C):
            c += (Y - X) * 2
        else:
            b = (Y - X)


price = a*A + b*B + c*C
print(price)

Submission status: Accepted

Solution code:
def C():
    A, B, C, nA, nB = map(int, input().split())
    minAB = min(nA, nB)
    # 3, 2 --> 1, 0
    ns = [nA - minAB, nB - minAB]
    amounts = [
        A * nA + B * nB,
        minAB * 2 * C + ns[0] * A + ns[1] * B,
        max(nA, nB) * 2 * C
    ]
    return min(amounts)

print(C())

Submission status: Accepted

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

print(min(cost))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print(min_sum)

Submission status: Accepted

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

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

print(min_sum)

Submission status: Accepted

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

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

Submission status: Accepted

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

ab = 2 * c
money = 0

if a + b >= ab:
    if x >= y:
        if  a >= ab:
            money = x * ab
        else:
            money = (x - y) * a + y * ab
    else:
        if b >= ab:
            money = y * ab 
        else:
            money = (y - x) * b + x * ab

else:

    if a < ab and b < ab:
        money = a*x + b*y

    if a >= ab and b < ab:
        if y - x >= 0:
            money = x * ab + b * (y - x)
        else:
            money = x * ab

    if a < ab and b >= ab:
        if x -y >= 0:
            money = y * ab + a * (x -y)
        else:
            money = y * ab

    if a >= ab and b >= ab:
        money = x * ab + y * ab

print(money)

Submission status: Accepted

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

cost = 0
n_small = min(X, Y)

if A + B > 2*C:
    cost += n_small * (2*C)
else:
    cost += n_small * (A+B)

X -= n_small
Y -= n_small

if X == 0:
    if B > 2*C:
        cost += Y * (2*C)
    else:
        cost += Y * B
else:
    if A > 2*C:
        cost += X * (2*C)
    else:
        cost += X * A
        
print(cost)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

def dp(num_a,num_b):
    """
    if num_a<=0 and num_b<=0:return 0
    elif num_b>0:
        if B<2*C:return B+dp(num_a,num_b-1)
        else :return C*2+dp(num_a-1,num_b-1)
    else:
        if A<2*C:return A+dp(num_a-1,num_b)
        else: return C*2+dp(num_a-1,num_b-1)
    """
    if A+B>2*C:
        if min(num_a,num_b)>0:
            if num_a > num_b:
                return num_b*2*C+dp(num_a-num_b,0)
            else :
                return num_a*2*C+dp(0,num_b-num_a)
        elif num_a==0 and num_b>0:
            if B<2*C:
                return num_b*B
            else :
                return C*2*num_b
        elif num_a>0 and num_b==0:
            if A<2*C:
                return A*num_a
            else :
                return 2*C*num_a
        else :
            return 0
    else :
        return num_a*A+num_b*B
print(dp(X,Y))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
line = list(map(int,input().split(" ")))
A,B,C,X,Y = line[0],line[1],line[2],line[3],line[4]

payment = 0
min_AB = min(X,Y)
if(A+B< 2 * C):
    payment += (A+B) * min_AB
else:
    payment += 2 * C * min_AB

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import random

#--------ピ　ザ　群　最　適　化------------------------------

#評価関数: 　双対問題
def criterion(x, y):
    z=xo*x+yo*y

    if x>a or y>b or x+y>2*c or x<0 or y<0:
        z=-z
    
    return z

#粒子の位置の更新を行う関数
def update_position(x, y, vx, vy):
 
    new_x = x + vx
    new_y = y + vy

    return new_x, new_y

#粒子の速度の更新を行う関数
def update_velocity(x, y, vx, vy, p, g, w=1, ro_max=0.5,v_max=10):
    #パラメーターroはランダムに与える
    ro1 =random.uniform(0, ro_max)
    ro2 =random.uniform(0, ro_max)
    #粒子速度の更新を行う
    new_vx = int((w * vx + ro1 * (p["x"] - x) + ro2 * (g["x"] - x)))
    new_vy = int((w * vy + ro1 * (p["y"] - y) + ro2 * (g["y"] - y)))
    if abs(new_vx)>v_max:
        new_vx=int(v_max*new_vx/abs(new_vx))
    if abs(new_vy)>v_max:
        new_vy=int(v_max*new_vy/abs(new_vy))

    #print(new_vx, new_vy)
    return new_vx, new_vy
    
def main():
    N = 2000  #粒子の数
    x_min, x_max = 0, a
    y_min, y_max = 0, b
    #粒子位置, 速度, パーソナルベスト, グローバルベストの初期化を行う
    ps = [{"x": random.randint(x_min, x_max), 
        "y": random.randint(y_min, y_max)} for i in range(N)]
    vs = [{"x": 0, "y": 0} for i in range(N)]

    personal_best_positions = list(ps)
    personal_best_scores = [criterion(p["x"], p["y"]) for p in ps]

    best_particle = personal_best_scores.index(max(personal_best_scores))
    global_best_position = personal_best_positions[best_particle]

    T = 100  #制限時間(ループの回数)
    for t in range(T):
        for n in range(N):
            x, y = ps[n]["x"], ps[n]["y"]
            vx, vy = vs[n]["x"], vs[n]["y"]
            p = personal_best_positions[n]
            #粒子の位置の更新を行う
            new_x, new_y = update_position(x, y, vx, vy)
            ps[n] = {"x": new_x, "y": new_y}
            #粒子の速度の更新を行う
            new_vx, new_vy = update_velocity(
                new_x, new_y, vx, vy, p, global_best_position)
            vs[n] = {"x": new_vx, "y": new_vy}
            #評価値を求め, パーソナルベストの更新を行う
            score = criterion(new_x, new_y)
            if score > personal_best_scores[n]:
                personal_best_scores[n] = score
                personal_best_positions[n] = {"x": new_x, "y": new_y}
        #グローバルベストの更新を行う
        best_particle = personal_best_scores.index(max(personal_best_scores))
        global_best_position = personal_best_positions[best_particle]
#        print(max(personal_best_scores), global_best_position["x"], global_best_position["y"])

    #最適解
    return max(personal_best_scores), global_best_position["x"], global_best_position["y"]


#--------------------------------------------------------------

a, b, c, xo, yo = [int(i) for i in input().split()]
#a, b, c, xo, yo = 1500, 2000, 500, 90000, 100000
best=-100000000
xx=0
yy=0
for i in range(3):
    kouho_best, kouho_x, kouho_y=main()
    if best<kouho_best:
        best=kouho_best
        xx=kouho_x
        yy=kouho_y

print(best)

Submission status: Accepted

Solution code:
S = map(int, raw_input().split())
A = S[0]
B = S[1]
C = S[2]
X = S[3]
Y = S[4]

if X > Y:
    A = S[1]
    B = S[0]
    X = S[4]
    Y = S[3]

totals = []
for i in range(Y + 1):
    total = 0
    total += C * 2 * i
    if i < X:
        total += A * (X - i)
    if i < Y:
        total += B * (Y - i)

    totals.append(total)

print(sorted(totals)[0])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding:utf-8 -*-
if __name__ == "__main__":
    a, b, c, x, y = map(int, input().split())
    ans = float('inf')
    for tmp in range((10**5)+1):
        ans = min(ans, a*max(0, x-tmp)+b*max(0,y-tmp)+c*2*tmp)
    else:
        print(ans)

Submission status: Accepted

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

ans1=max(X,Y)*C*2
ans2=X*A+Y*B
if X>Y:
  ans3=C*Y*2+(X-Y)*A
else:
  ans3=C*X*2+(Y-X)*B

print(min(ans1,ans2,ans3))

Submission status: Accepted

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

least_price = float("inf")
less_list = sorted([X, Y])

for i in range(less_list[1]+1):
    num_A = X- i
    num_B = Y - i
    
    if num_A <= 0 :
        num_A = 0
    if num_B <= 0:
        num_B = 0

    total_price = C * 2*i +  A * num_A + B * num_B
    if least_price > total_price:
            least_price = total_price
    else:
        pass

print(least_price)

Submission status: Accepted

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

byeEachAB = A * X + B * Y
byeABless = A * (X - min(X, Y)) + B * (Y - min(X, Y)) + C * min(X, Y) * 2
byeABmore = C * max(X, Y) * 2
print(min(byeEachAB, byeABless, byeABmore))

Submission status: Accepted

Solution code:

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

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

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

print(price)

Submission status: Accepted

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

#双対問題の最大化

gyou=4 #目的関数＋スラック変数λ1～λ3
retsu=6 #x, y＋スラック変数λ1～λ3＋定数項

matrix=[[0 for i in range(retsu)] for j in range(gyou)]

#評価関数
matrix[0][0], matrix[0][1]= -x, -y 
#ピッツァ
matrix[1][0], matrix[1][1]= 1, 0
matrix[2][0], matrix[2][1]= 0, 1
matrix[3][0], matrix[3][1]= 1, 1
#定数項
matrix[1][5], matrix[2][5], matrix[3][5]=a, b, 2*c

#スラック変数
matrix[1][2]=1
matrix[2][3]=1
matrix[3][4]=1

for i in range(10):
    if min(matrix[0])>=0:
        break
    else:
        p_column=min(enumerate(matrix[0]), key=lambda x: x[1])[0]
        const_per_p=[10**6 for i in range(gyou)]

    for j in range(gyou):
        if matrix[j][p_column]>0:
            const_per_p[j]=matrix[j][5]/matrix[j][p_column]

            k_row=min(enumerate(const_per_p), key=lambda x: x[1])[0]
            pivot=matrix[k_row][p_column]

            new_matrix=[[0 for i in range(retsu)] for j in range(gyou)]
            for l in range(gyou):
                for j in range(retsu):
                    if l==k_row:
                       new_matrix[l][j]/=pivot
                    else:
                       new_matrix[l][j]=matrix[l][j]-matrix[l][p_column]*matrix[k_row][j]/pivot

    matrix=new_matrix[:][:]

print(int(matrix[0][5]))

Submission status: Accepted

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

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

Submission status: Accepted

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

pay = 0

XY = min([X, Y])
X -= XY
Y -= XY

if (A+B) > C*2:
    pay += XY*C*2
else:
    pay += XY*A + XY*B

if A > C*2:
    pay += X*C*2
else:
    pay += X*A

if B > C*2:
    pay += Y*C*2
else:
    pay += Y*B

print(pay)

Submission status: Accepted

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


"""                                                                                                                                                                   
                                                                                                                                                                      
1500 2000 1600 3 2                                                                                                                                                    
                                                                                                                                                                      
A * 3 + B * 2                         = 8500                                                                                                                          
                                                                                                                                                                      
2C + A*2 + B * 1 = 3200 + 4000 + 1600 = 8800                                                                                                                          
4C + A*1 + B * 0 = 6400 + 1500        = 7900                                                                                                                          
6C                                    = 9600                                                                                                                          
                                                                                                                                                                      
"""

acc = []

maxC = 2 * max(X,Y) + 2

for i in range(maxC):
    x=i
    if x % 2 == 0:
        Csize = x/2
        remXsize = X - Csize
        remYsize = Y - Csize
        acc.append( C * x + A * max(remXsize,0) + B * max(remYsize,0) )

#print acc                                                                                                                                                            
print min(acc)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#coding: utf-8

s = input().split(" ")
a = int(s[0])
b = int(s[1])
c = int(s[2])
x = int(s[3])
y = int(s[4])

out = 0
if x > y:
    mx = (x - y , "a")
    my = y
else:
    mx = (y - x , "b")
    my = x

cc = min([a+b, c*2])
for i in range(my):
    out += cc
if mx[1] == "a":
    if cc > a:
        out += a * mx[0]
    else:
        out += cc * mx[0]
else:
    if cc > b:
        out += b * mx[0]
    else:
        out += cc * mx[0]

print(out)

Submission status: Accepted

Solution code:
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))

Submission status: Accepted

Solution code:
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)*(a if x>y else b)))

Submission status: Accepted

Solution code:
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]))

Submission status: Accepted

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

Submission status: Accepted

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

res = A * X + B * Y
for i in range(2, 4 * (X + Y) + 1,2):
	curr = max(0,A * (X - i // 2)) + max(0,B * (Y - i // 2)) + C * i
#	print(i,curr) 
	res = min(res, curr)

print(res)

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
a,b,c,x,y = [int(i) for i in input().split()]

min_price = a * x + b * y

for i in range(100001):
    sum_price = a * max(0, x - i) + b * max(0, y - i) + c * 2 * i
    if sum_price <= min_price:
        min_price = sum_price

print(min_price)

Submission status: Accepted

Solution code:
def parse_input(raw,format):
    raw=raw.split()
    format=format.split()

    ret={}
    rawpos=0
    for f in format:
        pass


def A(S):
    ret=700
    ret+=S.count("o")*100
    return ret

def B(N,X,m):
    ret=0
    X-=sum(m)
    ret+=len(m)

    ret+=int(X/min(m))

    return ret

def C(A,B,C,X,Y):
    both_price=min(A+B,C*2)
    A_price=min(A,C*2)
    B_price=min(B,C*2)

    both_num=min(X,Y)
    X_num=X-both_num
    Y_num=Y-both_num
    return both_price*both_num+X_num*A_price+Y_num*B_price

import sys

inp = sys.stdin.read().split()
inp=[int(i) for i in inp]
print(C(inp[0], inp[1], inp[2],inp[3],inp[4]))

Submission status: Accepted

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

sum1 = a * x + b * y
sum2 = c * 2 * max(x, y)
if x <= y:
    sum3 = c * 2 * x + b * (y - x)
else:
    sum3 = c * 2 * y + a * (x - y)
    
print(min(sum1, sum2, sum3))

Submission status: Accepted

Solution code:
a, b, c, x, y = map(int, input().split())
ans = max(0, x)*a + max(0, y)*b # ABピザを一枚も買わなかった時
for i in range(100001):
    tmp = i*2*c + max(0, x-i)*a + max(0, y-i)*b
    if ans > tmp:
        ans = tmp
print(ans)

Submission status: Accepted

Solution code:
def main():
    A, B, C, X, Y = [int(i) for i in input().split()]
#    print(A, B, C, X, Y)
    if((A + B) < C*2):
        result = A*X + B*Y
    else:
        if(X < Y):
            result = X * C * 2
            rem = Y - X
            if(B < C*2):
                result += B * rem
            else:
                result += C * rem*2
        else:
            result = Y * C * 2
            rem = X - Y
            if(A < C*2):
                result += A * rem
            else:
                result += C * rem*2
    
    print(result)
    
if __name__=="__main__":
    main()

Submission status: Accepted

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

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

Submission status: Accepted

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

ans = 10**8

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

Submission status: Accepted

Solution code:
# coding: utf-8
a,b,ab,x,y=map(int,input().split())
ans=0
if a+b>ab*2:
    mn=min(x,y)
    ans+=ab*2*mn
    x-=mn
    y-=mn
if a>ab*2:
    ans+=x*ab*2
    y-=x
else:
    ans+=x*a
if y>0:
    if b>ab*2:
        ans+=y*ab*2
    else:
        ans+=y*b
print(ans)

Submission status: Accepted

Solution code:
l = list(map(int, input().split()))

sum = 0
a = b = c = 0

if l[0] > l[2]*2 or l[1] > l[2]*2:
    c1 = c2 = 0
    if l[0] > l[2]*2:
        c1 = 2 * l[3]
    if l[1] > l[2]*2:
        c2 = 2 * l[4]
    c = max([c1, c2])
elif l[0]+l[1] > l[2]*2:
    c += min([l[3], l[4]])*2
else:
    a = l[3]
    b = l[4]


if a+c/2 < l[3]:
    a += l[3]-(c/2+a)
if b+c/2 < l[4]:
    b += l[4]-(c/2+b)

sum = a*l[0] + b*l[1] + c*l[2]

print(int(sum))

Submission status: Accepted

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

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

sum_cost = 0

# 両方必要な部分の計算
if x <= y:
    ryoho = x
else:
    ryoho = y
if (a + b)/ 2 <= ab:
    sum_cost += (a * ryoho)
    sum_cost += (b * ryoho)
else:
    sum_cost += (ab * ryoho * 2)

# 片方が多く必要な部分の計算
kataho = abs(x - y)
if x >= y:
    if a <= ab * 2:
        sum_cost += (a * kataho)
    else:
        sum_cost += (ab * kataho * 2)
else:
    if b <= ab * 2:
        sum_cost += (b * kataho)
    else:
        sum_cost += (ab * kataho * 2)

print(sum_cost)

Submission status: Accepted

Solution code:
import sys

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

best_price = sys.maxsize


for i in range(0, max(x, y) * 2 + 1, 2):
    rest_a = x
    rest_b = y

    if i // 2 >= x:
        rest_a = 0
    else:
        rest_a = x - i // 2

    if i // 2 >= y:
        rest_b = 0
    else:
        rest_b = y - i // 2

    price = rest_a * a + rest_b * b + c * i
    if price < best_price:
        best_price = price
    # print("buy a = " + str(rest_a) + ", b = " + str(rest_b) + ", c = " + str(i) + ", price = " + str(price))

print(best_price)

Submission status: Accepted

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

if A + B <= 2 * C:
    pri = A * X + B * Y
else:
    while min(X, Y) != 0:
        pri += C * 2
        X -= 1
        Y -= 1
    if A * X + B * Y >= 2 * C * (X + Y):
        pri += 2 * C * (X + Y)
    else:
        pri += A * X + B * Y

print(pri)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

print(minmoney)

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

print(ans)

Submission status: Accepted

Solution code:
A, B, C, X, Y = map(int, raw_input().split())
ans = 0
if A + B < C * 2:
  ans = A*X+B*Y
else:
  num_ab_a = X*2
  num_b_a = 0 if Y-X < 0 else Y-X
  ans_a = C*num_ab_a+B*num_b_a
  num_ab_b = Y*2
  num_a_b = 0 if X-Y < 0 else X-Y
  ans_b = C*num_ab_b+A*num_a_b
  ans = ans_a if ans_a < ans_b else ans_b
print ans

Submission status: Accepted

Solution code:
#abc095c

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

Submission status: Accepted

Solution code:
#abc095c

a,b,c,x,y=map(int,raw_input().split())
res=float('inf')
for i in xrange(100000+2):
 t=2*c*i+max(0,x-i)*a+max(0,y-i)*b
 res=min(res,t)
print res

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
import sys
l1 = input().split()
l2 = []
for num in l1:
    l2.append(int(num))
value = []
for c in range(0,2*max([l2[3],l2[4]])+1,2):
    a = max([l2[3]-(c/2),0])
    b = max([l2[4]-(c/2),0])                    
    value.append(int((a*l2[0])+(b*l2[1])+(c*l2[2    ])))
print(min(value))

Submission status: Accepted

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

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

	print(p)

Submission status: Accepted

Solution code:
def main():
    """
    1 <= A,B,C<=5*10^3
    1 <= X,Y<=10^5
    """
    A, B, C, X, Y = map(int, input().split())

    search(A, B, C, X, Y)

def search(A, B, C, X, Y):
    ans = float("inf")
    for a in range(X+1):
        ab = 2 * (X - a)
        b = max(Y - ab // 2, 0)
        price = A * a + B * b + C * ab
        ans = min(ans, price)

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

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

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
C - Half and Half
https://beta.atcoder.jp/contests/abc095/tasks/arc096_a

"""
import sys
from sys import stdin
input = stdin.readline


def solve(A, B, C, X, Y):
    if A + B <= 2 * C:
        return A * X + B * Y

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

    Y -= m
    if 2 * C < B:
        ans += 2 * C * Y
    else:
        ans += B * Y

    X -= m
    if 2 * C < A:
        ans += 2 * C * X
    else:
        ans += A * X

    return ans


def main(args):
    A, B, C, X, Y = map(int, input().split())
    ans = solve(A, B, C, X, Y)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])

Submission status: Accepted

Solution code:
def solve(a, b, c, x, y):
    flag = None
    if x < y:
        flag = True
    else:
        flag = False
    if c < (a / 2) and c < (b / 2):
        return c * max(x, y) * 2
    c_many = min(x, y)
    c_total = c * c_many * 2
    return min([
        (y - c_many) * b + c_total if flag else (x - c_many) * a + c_total, 
        a * x + b * y,
        max(x, y) * 2 * c,
    ])
   
if __name__ == '__main__':
    a, b, c, x, y = map(lambda x: int(x), input().split())

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a , b , c ,x , y = map(int , input().split())
c2 = c *2
na , nb ,nc = 0 , 0 ,0 
if a > c2 :
    a = c2
if b > c2 :
    b = c2

if a <= c2 and b <= c2 :
    if a + b >= c2 :
        nc = min(x,y)
        if x > y :
            na = x - y
        else :
            nb = y -x
    else :
        na = x
        nb = y
print(na*a+nb*b+nc*c2)

Submission status: Accepted

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

answer = a * x + b * y

while (2*c) < (a+b):
    if x >= 1 and y >= 1:
        answer = answer +  (2*c) - (a+b)
        x -= 1
        y -= 1
    else:
        break

while (2*c) < a:
    if x >= 1:
        answer = answer + (2*c) -a
        x -= 1
    else:
        break

while (2*c) < b:
    if y >= 1:
        answer = answer + (2*c) -b
        y -= 1
    else:
        break
print(answer)

Submission status: Accepted

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

# 個別買い
p1 = a * x + b * y

# セット＋残りを個別
p2 = c * min(x, y) * 2 + (a * (x - y) if x > y else b * (y - x))

# セットのみ
p3 = c*max(x, y)*2

print(min(p1, p2, p3))

Submission status: Accepted

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

# 個別買い
p1 = a * x + b * y

# セット＋残りを個別
p2 = c * min(x, y) * 2 + (a * (x - y) if x > y else b * (y - x))

# セットのみ
p3 = c*(x+y) * 2
p4 = c*max(x, y)*2

print(min(p1, p2, p3, p4))

Submission status: Accepted

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

if a + b // 2 < c:
    c = a + b // 2

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

v = 0

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

print(min(n, v, m))