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

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

Submission status: Accepted

Solution code:
def LI():return map(int,input().split())
def I(): return input().split()

a,b,c,x,y=LI()
lst=0
ans=float("inf")
for i in range(10**5+1):
    ans=min(ans,(2*i*c+max(0,x-i)*a+max(0,y-i)*b))
print(ans)

Submission status: Accepted

Solution code:
def LI():return map(int,input().split())
def I(): return input().split()

a,b,c,x,y=LI()
lst=[]
ans=0
for i in range(10**5+1):
    lst.append(2*i*c+max(0,x-i)*a+max(0,y-i)*b)
print(min(lst))

Submission status: Accepted

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

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

Submission status: Accepted

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

ans = 1 << 31

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

print(ans)

Submission status: Accepted

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

CtoAB1 =0
CtoAB2 =0
AandB =0

if X >= Y:
    CtoAB1=2*C*Y+A*(X-Y)
    CtoAB2=2*C*X
else:
    CtoAB1=2*C*X+B*(Y-X)
    CtoAB2=2*C*Y

AandB=A*X+B*Y

print(min(CtoAB1,CtoAB2,AandB))

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().strip()


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

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
A,B,C,X,Y=map(int,input().split())
check=[0]*4
check[0]=A*X+B*Y
check[1]=C*max(X,Y)*2
check[2]=C*Y*2+A*(X-Y) if X>Y else float('inf')
check[3]=C*X*2+B*(Y-X) if X<Y else float('inf')
print(min(check))

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
A, B, C, X, Y = map(int, input().split())

patterns = [0] * 4
patterns[0] = A * X + B * Y
patterns[1] = C * max(X, Y) * 2
patterns[2] = C * Y * 2 + A * (X - Y) if X > Y else float('inf')
patterns[3] = C * X * 2 + B * (Y - X) if X < Y else float('inf')

print(min(patterns))

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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


def get_input() -> tuple:
    """
    標準入力を取得する.

    Returns:\n
        tuple: 標準入力
    """
    A, B, C, X, Y = list(map(int, input().split()))

    return A, B, C, X, Y


def main(A: int, B: int, C: int, X: int, Y: int) -> None:
    """
    メイン処理.

    Args:\n
        A (int): Aピザの値段
        B (int): Bピザの値段
        C (int): ABピザの値段
        X (int): Aピザの必要枚数
        Y (int): Bピザの必要枚数
    """
    # 求解処理
    ans = sys.maxsize
    max_c = 2 * max(X, Y)
    for c in range(0, max_c + 1, 2):
        a = max(X - c // 2, 0)
        b = max(Y - c // 2, 0)
        price = a * A + b * B + c * C
        ans = min(ans, price)

    # 結果出力
    print(ans)


if __name__ == "__main__":
    # 標準入力を取得
    A, B, C, X, Y = get_input()

    # メイン処理
    main(A, B, C, X, Y)

Submission status: Accepted

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

# 標準入力を取得
A, B, C, X, Y = list(map(int, input().split()))

# 求解処理
ans = sys.maxsize
max_c = 2 * max(X, Y)
for c in range(0, max_c + 1, 2):
    a = max(X - c // 2, 0)
    b = max(Y - c // 2, 0)
    price = a * A + b * B + c * C
    ans = min(ans, price)

# 結果出力
print(ans)

Submission status: Accepted

Solution code:
def main():
    A, B, C, X, Y = map(int, input().split())
    ans = 10**10
    max_c = max(X, Y) + 1
    for i in range(max_c):
        num_c = i * 2
        num_a = max(0, X - i)
        num_b = max(0, Y - i)
        price = num_a * A + num_b * B + num_c * C
        ans = min(price, ans)
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def main():
    A, B, C, X, Y = map(int, input().split())
    if A >= 2*C and B >= 2*C:
        ans = max(X, Y) * 2 * C
        print(ans)
        return
    if A>= 2*C:
        num_c = X * 2
        ans = num_c * C
        if Y * 2 > num_c:
            ans += (Y - num_c//2) * B
        print(ans)
        return
    if B >= 2*C:
        num_c = Y * 2
        ans = num_c * C
        if X * 2 > num_c:
            ans += (X - num_c//2) * A
        print(ans)
        return
    if A + B >= 2*C:
        num_c = min(X, Y) * 2
        ans = num_c * C
        ans += (X - num_c//2) * A
        ans += (Y - num_c//2) * B
        print(ans)
        return
    ans = X * A + Y * B
    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
""" tutorial05
    https://atcoder.jp/contests/abc095/tasks/arc096_a
"""
import sys
import math
from functools import reduce

def readStringSet(n):
    return sys.stdin.readline().split(" ")[:n]

def readIntegerSet(n):
    return list(map(int, readStringSet(n)))

def main(A, B, C, X, Y):
    """ main
    """
    if A + B > 2 * C:
        result = min([X, Y]) * 2 * C

        if X > Y:
            if A > 2 * C:
                return result + (X - Y) * 2 * C
            else:
                return result + (X - Y) * A
        else:
            if B > 2 * C:
                return result + (Y - X) * 2 * C
            else:
                return result + (Y - X) * B
    else:
        return X * A + Y * B

if __name__ == "__main__":
    _A, _B, _C, _X, _Y = readIntegerSet(5)

    print(main(_A, _B, _C, _X, _Y))

Submission status: Accepted

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

    ans1 = x*a + y*b
    min_num = min(x, y)
    max_num = max(x, y)
    x, y = x-min_num, y-min_num
    ans2 = min_num*c*2 + max(x, 0)*a + max(y, 0)*b
    ans3 = max_num*c*2
    ans = min(ans1, ans2, ans3)
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
A,B,C,X,Y=map(int,input().split())
"""
X枚のA、Y枚のBが必要
ABピザの値段2枚が安いかどうかが分かれ目
"""
ans=(X+Y)*(A+B+C)
#2枚のピザのほうが安いとき
for i in reversed(range(max(X,Y)+1)):#全部ABピザにしちゃう場合から
    num_c=i*2
    num_a=max(0,X-i)
    num_b=max(0,Y-i)
    if ans>num_a*A+num_b*B+num_c*C:
        ans=num_a*A+num_b*B+num_c*C
print(ans)

Submission status: Accepted

Solution code:
A,B,C,X,Y=map(int,input().split())
"""
X枚のA、Y枚のBが必要
ABピザの値段2枚が安いかどうかが分かれ目
"""
ans=(X+Y)*(A+B+C)
#2枚のピザのほうが安いとき
for i in reversed(range(max(X,Y)+1)):#全部ABピザにしちゃう場合から
    num_c=i*2
    num_a=max(0,X-i)
    num_b=max(0,Y-i)
    if ans>num_a*A+num_b*B+num_c*C:
        ans=num_a*A+num_b*B+num_c*C
    else:
        break
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

min_total = float("inf")
for i in range(max(X, Y) + 1):
    sum_C = 2 * C * i
    sum_A = A * max(0, X - i)
    sum_B = B * max(0, Y - i)
    total = sum_C + sum_A + sum_B
    if total < min_total:
        min_total = total

print(min_total)

Submission status: Accepted

Solution code:
def main():
    A, B, C, X, Y = map(int, input().split())
    prices = sorted([(X, A, C), (Y, B, C)], key=lambda x: x[0])
    min_price = 1e10
    for i in range(prices[0][0]+1):
        tmp_price = prices[0][1] * i + 2 * prices[0][2] * (prices[0][0]-i)
        rest = prices[1][0] - (prices[0][0]-i)
        tmp_price += min(rest * prices[1][1], 2 * rest * prices[1][2])
        min_price = min(min_price, tmp_price)

    print(min_price)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:

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

n = a*x+b*y

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

if x<y:
    p = b
else:
    p = a

l = 2*c*min(x,y) + p*abs(x-y)

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

print(ans)

Submission status: Accepted

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

min_xy = min(x, y) 
max_xy = max(x, y)

min_xy_cost = min(a + b, c * 2) * min_xy

if x >= y:
  rest = x - y
  rest_cost = rest * min(a, c * 2)
else:
  rest = y - x
  rest_cost = rest * min(b, c * 2)
  
total = min_xy_cost + rest_cost

print(total)

Submission status: Accepted

Solution code:
import sys
import math

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

ans = 10**15
a = []

for i in range(max(X, Y)+1):
    if X-i < 0:
        money = B*(Y-i) + 2 * C * i
    elif Y-i < 0:
        money = A*(X-i) + 2 * C * i
    else:
        money = A*(X-i) + B*(Y-i) + 2*C*i
    a.append(money)


print(min(a))

Submission status: Accepted

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

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

Submission status: Accepted

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

mi=min([x,y])
ma=max([x,y])
g=ma-mi
ans,ab=0,0


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

if ab >= ans: 
  print(ans)
else:
  if ab!=0:
    print(ab)
  else:
    print(ans)

Submission status: Accepted

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

cnt = max(x, y)

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

print(ans)

Submission status: Accepted

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

price = X * A + Y * B
for a in [0,abs(X-Y),X]:
    for b in [0,abs(X-Y),Y]:
        c = max(X-a,Y-b)*2
        price = min(price,a*A + b*B + c*C)

print(price)

Submission status: Accepted

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

ans = A * X + B * Y

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

print(min(ans, ans1,ans2))

Submission status: Accepted

Solution code:
a,b,c,x,y = map(int, input().split())
kei = 0
if c >= a/2 + b/2:
    kei = a * x + b*y

elif c*2 <= a+ b and a >= c * 2 and x > y:
    kei += c * (min(x,y)*2)
    kei += c * ((x - y)*2)

elif c*2 <= a+ b and b >= c * 2 and x < y:
    kei += c * (min(x,y)*2)
    kei += c * ((y - x)*2)

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


print(kei)

Submission status: Accepted

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

values = []

values.append(A*X + B*Y)

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

print(min(values))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A,B,C,x,y = map(int,input().split())
ans = 0
if A+B > 2*C:
    ans += min(x,y)*C*2
else:
    ans += x*A + y*B
    print(ans)
    exit()    

if x >= y:
    x -= y
    y = 0
    if A <2*C:
        ans += x*A
    else:
        ans += x*2*C    
else:
    y -= x
    x = 0
    if B < 2*C:
        ans += y*B
    else:
        ans += y*2*C
print(ans)

Submission status: Accepted

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

cost = 0

while x>0 or y>0:
  
  if a+b>=2*c:
    while x>0 and y>0:
      cost += 2*c
      x -= 1
      y -= 1
      
  if x>0:
    if a>=2*c:
      cost += 2*c
    else:
      cost += a
    x -= 1
  elif y>0:
    if b>=2*c:
      cost += 2*c
    else:
      cost += b
    y -= 1
    
print(cost)

Submission status: Accepted

Solution code:
a, b, c, x, y = map(int, input().split())
# ピザの枚数a,b,cについては
# 2c = a+b が成り立つ
# cを奇数個買ってもこの問題の場合意味がないので基本2cで考える

ans = float('inf')
# cをi枚買ったとする。
# x,y <= 10^5 なので100000+1回しとけば問題なし
for i in range(100001):
    ans = min(ans, (2*c)*i + a*max(x-i,0) + b*max(y-i,0))
print(ans)

Submission status: Accepted

Solution code:
import sys

def input():
    return sys.stdin.readline()[:-1]

def mi():
    return map(int, input().split())

def ii():
    return int(input())

def main():
    A, B, C, X, Y = mi()

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

mins, maxs = min(x,y), max(x,y)
diff = maxs - mins

total = min((a+b) * mins, c * mins*2)

pp = a if x > y else b
total += (pp if pp < c * 2 else c * 2 ) * diff
print(total)

Submission status: Accepted

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

else:
    ans+=x*a+y*b

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
A, B, C, X, Y = map(int, input().split())
ans = 0
#A+B < 2ABの場合はそれぞれ単品で買ったほうがお得
if A + B < 2 * C:
    ans = A*X + B*Y
#A+B > 2ABの場合は買えるだけかう
else:
    for _ in range(min(X, Y)):
        ans += 2 * C

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

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

print(ans)

Submission status: Accepted

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

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

print(res)

Submission status: Accepted

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

Submission status: Accepted

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

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

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

print(aaa)

Submission status: Accepted

Solution code:
a,b,c,x,y=map(int,input().split())
money=0
ans=float("INF")

money=a*x+b*y
ans=min(money,ans)
#print(ans)

money=2*min(x,y)*c+(x-min(x,y))*a+(y-min(x,y))*b
ans=min(money,ans)
#print(min(x,y),ans)

money=2*c*max(x,y)
ans=min(money,ans)

print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# coding: utf-8

# In[8]:


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


# In[10]:


ans1 = A*X + B*Y
ans2 = C*min(X,Y)*2 + A*(X-min(X,Y)) + B*(Y-min(X,Y))
ans3 = C*max(X,Y)*2
print(min(ans1, ans2, ans3))


# In[ ]:

Submission status: Accepted

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

ans = 10000 * (10 **5) + 7
c_max = 0
if x > y:
  c_max = x * 2
else:
  c_max = y * 2

for cc in range(0, c_max+1, 2):
  ac = x - (cc // 2)
  bc = y - (cc // 2)
  
  if ac < 0:
    ac = 0
  if bc < 0:
    bc = 0
  price = ac * a + bc * b + cc * c
  # print('price: {}, ac: {}, bc: {}, cc: {}'.format(price, ac, bc, cc))
  ans = min(ans, price)

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

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

for c in range(0, max(2*X, 2*Y)+1, 2):
  a = max(0, math.ceil(X-0.5*c))
  b = max(0, math.ceil(Y-0.5*c))
  if A*a + B*b + C*c < lowest:
    lowest = A*a + B*b + C*c

print(lowest)

Submission status: Accepted

Solution code:
import math

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

for a in range(0, X+1):
  c = (X-a)*2
  if Y - 0.5*c < 0:
    b = 0
  else:
    b = math.ceil(Y - 0.5*c)
  if A*a + B*b + C*c < lowest:
    lowest = A*a + B*b + C*c
    
for b in range(0, Y+1):
  c = (Y-b)*2
  if X - 0.5*c < 0:
    a = 0
  else:
    a = math.ceil(X - 0.5*c)
  if A*a + B*b + C*c < lowest:
    lowest = A*a + B*b + C*c

print(lowest)

Submission status: Accepted

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

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

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


print(a)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def resolve():
    A, B, C, X, Y = list(map(int, input().split()))
    ans = []
    for i in range(0, 100000+1):
        ans.append(i * 2 * C + max(0, X - i) * A + max(0, Y - i) * B)
    print(min(ans))
    return


resolve()

Submission status: Accepted

Solution code:
a, b, c, x, y = map(int, input().split())
l = []
l.append(a*x + b*y)
l.append(2*c * max(x, y))

if x < y:
    l.append(2*c*x + b*(y-x))
elif x > y:
    l.append(2*c*y + a*(x-y))

print(min(l))

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import itertools
# import numpy as np
import time
import math
 
sys.setrecursionlimit(10 ** 7)
 
from collections import defaultdict
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

ans = 10 ** 10
for c in range(2 * 10 ** 5 + 1):
    a = X - c // 2
    b = Y - c // 2
    if a < 0:
        a = 0
    if b < 0:
        b = 0
    ans = min(ans, A * a + B * b + C * c)
print(ans)

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

p1 = a * x + b * y
if y >= x:
    p2 = c * x * 2 + b * (y - x)
else:
    p2 = a * (x - y) + c * y * 2
p3 = c * max(x, y) * 2

print(min(p1,p2,p3))

Submission status: Accepted

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

print(output)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def resolve():
    import sys
    input = sys.stdin.readline    
    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)+c*z*2,max(x,y)*2*c)
    print(ans)

if __name__ == '__main__':
    resolve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
def main():
    A, B, C, X, Y =map(int, input().split())
    ans = min(min(2*X*C + max((Y-X)*B, 0), 2*Y*C + max((X-Y)*A, 0)), A*X + B*Y)
    print(ans)    

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
#<100q.全探索（計算量注意）>
a, b, c, x, y = map(int,input().split())
ans1 = a * x + b * y
if x <= y:
    ans2 = c * 2 * x + b * (y - x)
    ans5 = c * 2 * y
else:
    ans2 = c * 2 * y + a * (x - y)
    ans5 = c * 2 * x
ans3 = a * x + c * 2 * y
ans4 = b * y + c * 2 * x
##print(ans1)
##print(ans2)
##print(ans3)
##print(ans4)
##print(ans5)
print(min(ans1,ans2, ans3, ans4, ans5))

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

cost = a * x + b * y
n = max(x, y)

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

print(cost)

Submission status: Accepted

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

for i in range(100001):
    price = 2*C*i + A*max(0,X-i) + B*max(0,Y-i)
    list.append(price)

print(min(list))

Submission status: Accepted

Solution code:
import sys


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

    min_price = None

    for i in range(max(x, y) + 1):
        nc = i * 2
        na = x - i
        if na < 0:
            na = 0
        nb = y - i
        if nb < 0:
            nb = 0

        price = na * a + nb * b + nc * c
        if min_price is None or price < min_price:
            min_price = price

    print(min_price)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# 5
# ABC095 C Half and Half

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b,c,x,y = map(int,input().split())
ab = c*2 #A,B１枚ずつ入手
if ab <= a+b:
    bab = min(x,y)*ab
    if x > y:
        bother = (max(x,y)-min(x,y))*a
    else:
        bother = (max(x,y)-min(x,y))*b
    ans = min(bab+bother,ab*max(x,y))
else:
    bab = 0
    bother = a*x + b*y
    ans = bab + bother
print(ans)

Submission status: Accepted

Solution code:
import sys
from collections import deque
from itertools import *


def I(): return int(sys.stdin.readline().rstrip())


def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))


def S(): return sys.stdin.readline().rstrip()


def LS(): return list(sys.stdin.readline().rstrip().split())


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

Submission status: Accepted

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

Submission status: Accepted

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

ans = min(X,Y)*min(2*AB, A+B)
cnt_A = min(X,Y)
cnt_B = min(X,Y)

#残り
if X > cnt_A:#Aが足りないときa
    ans += min(2*AB,A)*(X-cnt_A)
else:#Bが足りないとき
    ans += min(2*AB,B)*(Y-cnt_B)
    
print(ans)

Submission status: Accepted

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

ans=10**9

my_min=min(X,Y)
my_max=max(X,Y)

ans1=2*C*my_min+A*(X-my_min)+B*(Y-my_min)
ans2=2*C*my_max
ans3=A*X+B*Y
print(min(ans1,ans2,ans3))

Submission status: Accepted

Solution code:
A, B, C, X, Y = map(int, input().split())
sum = 0
min_num = 10**10
num = [0]*3
for c in range(max(X, Y)+1):
    sum += C*c*2
    num[0] = c*2
    sum += A*max(0,X-c) + B*max(0, Y-c)
    num[1] = max(0, X-c)
    num[2] = max(0, Y-c)
    if min_num > sum:
        min_num = sum
    sum = 0
print(min_num)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
a,b,c,x,y=map(int,input().split())
minpr=10e+10
memo=None
if x>=y:
  for i in range(x+1):
    price= i*a+ 2*(x-i)*c+ max(0,y-(x-i))*b
    minpr=min(price,minpr)
  print(minpr)
else:
  
  for i in range(y+1):
    price= i*b+ 2*(y-i)*c+ max(0,x-(y-i))*a
    minpr=min(price,minpr)
  print(minpr)

Submission status: Accepted

Solution code:
def resolve():
    import math
    A, B, C, X, Y = map(int, input().split())
    ans = []
    for i in range(max(X, Y)*2+1):
        ans.append(C*i + A*(max(X-i/2, 0)) + B*(max(Y-i/2, 0)))
    print(math.floor(min(ans)))
resolve()

Submission status: Accepted

Solution code:
def main():
    a,b,ab,ac,bc = map(int,input().split())
    price = 0
    if a+b < ab*2:
        price = a*ac + b*bc
    else:
        if ac < bc:
            price += ab*ac*2
            x = bc-ac
            price += min(x*b, x*ab*2)
        else:
            price += ab*bc*2
            x = ac-bc
            price += min(x*a, x*ab*2)
    print(price)

if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def solve(a,b,c,x,y):
  l = []
  for i in range(10**6):
    s = a*max(x-i,0)+b*max(y-i,0)+c*i*2
    l.append(s)
  return min(l)

        

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