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] = [int(x) for x in input().split()]

total_price = a*x+b*y
max_num = max(x,y)

for i in range(0,(max_num+1)*2,2):
    new_x = 0 if x-i//2 <= 0 else x-i//2
    new_y = 0 if y-i//2 <= 0 else y-i//2
    current_price = i*c + new_x*a + new_y*b
    
    if current_price < total_price:
        total_price = current_price

print(total_price)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import Counter,defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,fractions
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys

def solve():
    input = sys.stdin.readline
    A, B, C, X, Y = map(int, input().split())
    if X > Y:
        X, Y = Y, X
        A, B = B, A
    C *= 2
    AB = A * X + B * Y
    allC = C * Y
    CB = C * X + B * (Y - X)
    print(min([AB, allC, CB]))
    
    
    return 0

if __name__ == "__main__":
    solve()

Submission status: Accepted

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

A = a * x + b * y
if x <= y: B = c * x * 2 + b * (y-x)
else: B = c * y * 2 + a * (x-y)
C = c * max(x, y) * 2

print(min(A, B, C))

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

print(ans)

Submission status: Accepted

Solution code:
A,B,C,X,Y = map(int, input().split())
ans = 5000 * 10**5 * 4 + 1
for c in range(0,max(X,Y)*2+1,2):
    a = c * C
    x,y = max(0,X-c//2), max(0,Y-c//2)
    a += A*x + B*y
    ans = min(ans, a)

print(ans)

Submission status: Accepted

Solution code:
a,b,c,x,y = map(int,input().split())
d = c * 2 #aピザ1枚とbピザ1枚
if a + b < d:
    print(x * a + y * b)
    exit()
elif x >= y:
    tmp1 = y * d + (x - y) * a
    tmp2 = x * d
    print(min(tmp1, tmp2))
elif y > x:
    tmp1 = x * d + (y - x) * b
    tmp2 = y * d
    print(min(tmp1, tmp2))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    a, b, c, x, y = (int(i) for i in input().split())
    ans = 0
    if x > y:
        p = (x - y)*a
    elif y > x:
        p = (y - x)*b
    else:
        p = 0
    print(min(a*x + b*y, 2*c*max(x, y), 2*c*min(x, y) + p))


if __name__ == '__main__':
    main()

Submission status: Accepted

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

AB_set = C * 2

ans = min(A*X + B*Y, AB_set*max(X,Y), AB_set*min(X,Y) + A*abs(X-min(X,Y)) + B*abs(Y-min(X,Y)))

print(ans)

Submission status: Accepted

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

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

# 偏り分
if 2 * C < A:
    k = X
    X -= k
    Y -= k
    ans += 2 * C * k
if 2 * C < B:
    k = Y
    X -= k
    Y -= k
    ans += 2 * C * k

# あまり分
ans += A * max(0, X) + B * max(0, Y)
print(ans)

Submission status: Accepted

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

ans = A*X + B*Y

i = 1
while True:
    cost = A*max(X-i, 0) + B*max(Y-i, 0) + 2*C*i
    if cost > ans:
        break
    ans = min(cost, ans)
    i += 1

print(ans)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
a,b,c,x,y=map(int,input().split())
#A,Bをそれぞれ買う
cand1=a*x+b*y
#すべてABピザでそろえる
cand2=2*c*max(x,y)
#A,Bのうち必要枚数が少ないほうをすべてABピザで作る
cand3=2*c*x+b*(y-x) if x<y else 2*c*y+a*(x-y)
print(min(cand1,cand2,cand3))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
A, B, C, X, Y = list(map(int,input().split()))
ans = float('Inf')
for i in range(max(X,Y)*2+1):
    tmp = i * C
    if i / 2 < X:
        tmp += A*(X-i//2)
    if i / 2 < Y:
        tmp += B*(Y-i//2)
    ans = min(ans,tmp)
print(ans)

Submission status: Accepted

Solution code:
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

a, b, c, x, y = mi()
n_min = min(x,y)
price = 0
if(a+b > 2*c):
    price += 2*c * n_min
else:
    price += (a+b) * n_min

if(x>y):
    n_mod = x-n_min
    d = a
else:
    n_mod = y-n_min
    d = b

if(d < c*2):
    price += d * n_mod
else:
    price += c*2 * n_mod

print(price)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

import numpy as np
import math, string, itertools, fractions, heapq, collections, re, array, bisect, copy, functools, random
from collections import deque, defaultdict, Counter
from heapq import heappush, heappop
from itertools import permutations, combinations, product, accumulate, groupby
from bisect import bisect_left, bisect_right, insort_left, insort_right
from operator import itemgetter as ig
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20
INF = float("INF")
mod = 10 ** 9 + 7
"""dd = [(-1, 0), (0, 1), (1, 0), (0, -1)];
ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)];
ddn9 = ddn + [(0, 0)]
for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:"""

def wi(): return list(map(int, sys.stdin.readline().split()))
def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]  # WideIntPoint
def ws(): return sys.stdin.readline().split()
def si(): return int(sys.stdin.readline())  # SingleInt
def ss(): return input()
def hi(n): return [si() for _ in range(n)]
def hs(n): return [ss() for _ in range(n)]  # HeightString
def s_list(): return list(input())
def mi(n): return [wi() for _ in range(n)]  # MatrixInt
def mip(n): return [wip() for _ in range(n)]
def ms(n): return [ws() for _ in range(n)]
def num_grid(n): return [[int(i) for i in sys.stdin.readline().split()[0]] for _ in range(n)]  # NumberGrid
def grid(n): return [s_list() for _ in range(n)]


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

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

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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
def main():
    #from sys import stdin, setrecursionlimit
    #setrecursionlimit(10**9)
    #r = input()
    #n = int(input())
    #a, b = map(int, input().split())
    #s, y = input().split()
    #a = input().split()
    #a = [int(input()) for i in range(n)]
    #a = list(map(int, input().split()))
    #a = [list(map(int, input().split())) for i in range(n)]
    #a = [int(s) - 1 for s in input().split()]
    #l=[int(input()) for _ in range(int(input()))]
    #res = 0
    n = list(map(int,input().split()))
    maisu = max(n[3],n[4])
    ans = [0]*(maisu+1)
    for i in range(maisu+1):
        ans[i] = n[2]*i*2+n[0]*max(0,(n[3]-i))+n[1]*max(0,(n[4]-i))
    print(min(ans))

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

ans = 0

# まずABを買う
ab = min(A + B, C*2)
buy = min(X, Y)
ans += ab * buy

X -= buy
Y -= buy

# 残りを買う
ans += min(A, 2 * C) * X
ans += min(B, 2 * C) * Y


print(ans)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**9)
A, B, C, X, Y = map(int, input().split())

cost1 = A * X + B * Y
cost2 = max(X, Y) * 2 * C
if X <= Y:
    cost3 = X * 2 * C + (Y - X) * B
else:
    cost3 = Y * 2 * C + (X - Y) * A

print(min([cost1, cost2, cost3]))

Submission status: Accepted

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

mid = min(x,y)
rest = max(x,y)-mid
if x>y: a_b = a
else: a_b = b

total = 0
# until mid
if 2*c <  a+b:
    total += mid*2 *c
else:
    total += mid   *(a+b)
    
#until end
if 2*c < a_b:
    total += rest*2 *c
else:
    total += rest   *a_b

print(total)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A,B,C,X,Y=map(int,input().split())
ans_2=A*X+B*Y
ans=min(X,Y)*2*C
mindelta_X=A*(max(X,Y)-min(X,Y))
mindelta_Y=B*(max(X,Y)-min(X,Y))


for i in range(1,max(X,Y)+1-min(X,Y)):
    delta=0
    if X>Y:
        delta=2*C*i+A*(max(X,Y)-min(X,Y)-i)
        if delta<mindelta_X:
            mindelta_X=delta
    if Y>X:
        delta=2*C*i+B*(max(X,Y)-min(X,Y)-i)
        if delta<mindelta_Y:
            mindelta_Y=delta

print(min([ans+mindelta_X,ans_2]) if X>Y else min([ans+mindelta_Y,ans_2]))

Submission status: Accepted

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

Submission status: Accepted

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

min_value = X if (X < Y) else Y

total = 0
if (A + B > C * 2):
  total = C * 2 * min_value
else:
  total = (A + B) * min_value

current_X = X - min_value
current_Y = Y - min_value
if(current_X != 0):
  if(A > C * 2):
    total += current_X * C * 2
  else:
    total += current_X * A
else:
  if(B > C * 2):
    total += current_Y * C * 2
  else:
    total += current_Y * B
print(total)

Submission status: Accepted

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

C = max(x, y) * 2 * c
print(min(A, B, C))

Submission status: Accepted

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

ans = 10 ** 18

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

h = a*x+b*y
i = a*(x-min([x,y]))+b*(y-min([x,y]))+2*c*min([x,y])
j = 2*c*max([x, y])
print(min([h, i, j]))

Submission status: Accepted

Solution code:
a, b, c, x, y = map(int, input().split())
ans = float('inf')
for i in range(100001):
    ans = min(ans, c * 2 * i + 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())
ans = min(a + b, c * 2) * min(x, y)
if x > y:
    ans += (x - y) * min(a, c * 2)
elif y > x:
    ans += (y - x) * min(b, c * 2)
print(ans)

Submission status: Accepted

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

a, b, c, x, y = map(int, input().split())
ab = 2 * c
m = 10 ** 9
for i in range(0, max(x, y) + 1):
    p = ab * i + a * max(0, x - i) + b * max(0, y - i)
    if m > p:
        m = p
print(m)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

maxV = max(X, Y)
min_prise = pow(10, 10)

# ABピザの枚数をiとする
for AB_cnt in range(maxV * 2 + 1):
  # Aの金額を計算する
  if X - AB_cnt // 2 > 0:
    A_prise = (X - AB_cnt // 2) * A
  else:
    A_prise = 0

  # Bの金額を計算する
  if Y - AB_cnt // 2 > 0:
    B_prise = (Y - AB_cnt // 2) * B
  else:
    B_prise = 0

  # ABの金額を計算する
  AB_prise = AB_cnt * C

  # A, B, ABの金額を合計する
  sum_prise = A_prise + B_prise + AB_prise

  # sum_priseが最小値よりも小さければ格納する
  if sum_prise < min_prise:
    min_prise = sum_prise

print(min_prise)

Submission status: Accepted

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

cost = float("inf")
for i in range(100001):
    tc = c * i * 2 + max(a * (x - i), 0) + max(b * (y - i), 0)

    cost = min(cost, tc)

print(cost)

Submission status: Accepted

Solution code:
def main():
    a, b, ab, x, y = map(int, input().split())
    # abをx枚買うかy枚買うか、0枚買うかの3パターン
    ab *= 2
    ab_x = ab * x + b * max((y - x), 0)
    ab_y = ab * y + a * max((x - y), 0)
    ab_0 = a * x + b * y
    print(min(ab_x, ab_y, ab_0))


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
#import math
#import bisect
#import numpy as np
import sys
input = sys.stdin.readline
MOD = 10**9 + 7
INF = float('INF')

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

    cm = 2 * max(x, y)
    ans = INF

    for cbuy in range(cm+1):
        xbuy = max(0, x - (cbuy//2))
        ybuy = max(0, y - (cbuy//2))
        price = xbuy * a + ybuy * b + cbuy * c
        ans = min(ans, price)

    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
A,B,C,X,Y=map(int,input().split())
l=[[A,X],[B,Y]]
l.sort(key=lambda x:x[1], reverse=True)
#print(l)
if (A+B)>2*C:
    l[0][1]=l[0][1]-min(X,Y)
    l[1][1]=l[1][1]-min(X,Y)
    if l[0][1]*l[0][0]<C*2*l[0][1]:
        print(2*C*min(X,Y)+l[0][1]*l[0][0])
    else:
        print(2*C*max(X,Y))
else:
    print(A*X+B*Y)

Submission status: Accepted

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

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

cost = int(1e10)
for num_ac in range(0, int(1e5) + 1):
    num_A = max(0, X - num_ac)
    num_B = max(0, Y - num_ac)
    c = 2 * C * num_ac + A * num_A + B * num_B
    cost = min(c, cost)
print(cost)

Submission status: Accepted

Solution code:
A,B,AB,X,Y= list(map(int, input().split()))
ans = (X * A) + (Y * B)
max_ab_cnt = max(X,Y)
for ab_cnt in range(max_ab_cnt+1):
    a_cnt = max(X - ab_cnt, 0)
    b_cnt = max(Y - ab_cnt,0)
    tmp = (a_cnt *A) + (ab_cnt * 2 * AB) + (b_cnt * B)
    ans = min(ans, tmp)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

ans = float("inf")
for k in range(0, max(x, y)*2+1, 2):
    i = 0 if x-k//2 < 0 else x-k//2
    j = 0 if y-k//2 < 0 else y-k//2
    ans = min(ans, a*i+b*j+c*k)

print(ans)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

# ABを買わない、AorBを買わない、AandBを買わない
if x >= y:
    print(min(x*a + y*b, 2*y*c + (x - y)*a, 2*x*c))
else:
    print(min(x*a + y*b, 2*x*c + (y - x)*b, 2*y*c))

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
import sys

def solve():
    A, B, C, X, Y = map(int, input().split())
    C *= 2
    if X > Y:
        X, Y = Y, X
        A, B = B, A
    
    minCost = A * X + B * Y
    allC = Y * C
    XCYB = X * C + (Y - X) * B
    print(min(minCost, min(allC, XCYB)))
   
    return 0

if __name__ == "__main__":
    solve()

Submission status: Accepted

Solution code:
A, B, C, X, Y = [int(x) for x in input().split()]
ans = 10 ** 10
C *= 2
for i in range(1 + 10 ** 5):
    cnt = C * i
    cnt += A * max(X - i, 0) + B * max(Y - i, 0)
    ans = min(ans, cnt)
print(ans)

Submission status: Accepted

Solution code:
A, B, C, X, Y = [int(x) for x in input().split()]
ans = 0
#A, Bを1枚ずつ同時
if A + B >= 2 * C:
    c = min(X, Y)
    ans += c * 2 * C
    X -= c
    Y -= c

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

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

print(ans)

Submission status: Accepted

Solution code:
A, B, C, X, Y = map(int, input().split())
pair = min(A + B, 2 * C) 
ans = 0
remained_X = X!=0
remained_Y = Y!=0

while X != 0 and Y != 0:
    ans += pair
    X -= 1
    Y -= 1

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

print(ans)

Submission status: Accepted

Solution code:
import math
import copy
from operator import mul
from functools import reduce
from collections import defaultdict
from collections import Counter
from collections import deque
# 直積 A={a, b, c}, B={d, e}:のとき，A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
from bisect import bisect_left, bisect_right
# import numpy as np

def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W

# 四方向: 右, 下, 左, 上
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]

def i_inpl(): return int(input())
def l_inpl(): return list(map(int, input().split()))
INF = float("inf")

######
# URL: https://atcoder.jp/contests/abc095/tasks/arc096_a
######

def main():
    a, b, c, x, y = l_inpl()
    ans = INF
    for i in range(max(x, y)*2+2):
        j = max(0, x-i//2)
        k = max(0, y-i//2)
        ans = min(ans, i*c+j*a+k*b)
    print(ans)
if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:


import math
def solve():
  a,b,c,x,y = (int(i) for i in input().split())
  ans = 10**15
  for ab in range(max(x,y)+15):
    cost = 0
    buyab = ab*2
    cost += buyab*c
    cost += a*max(x-ab,0) + b*max(y-ab,0)
    
    ans = min(cost,ans)
  print(ans)
solve()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

res = float('inf')
for c in range(10**5+1):
    a = X-c
    b = Y-c
    cost = C*c*2
    cost += max(a,0)*A
    cost += max(b,0)*B
    res = min(res, cost)
print(res)

Submission status: Accepted

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

Submission status: Accepted

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

ans=10**10
# ABピザの枚数を全探索
for i in range(0,max(X,Y)*2+1,2):
  cost=i*C
  cost+=max(X-i//2,0)*A
  cost+=max(Y-i//2,0)*B
  if cost<ans:
    ans=cost
print(ans)

Submission status: Accepted

Solution code:
# coding:utf-8

import sys
import math
import time
#import numpy as np
import collections
from collections import deque
import queue
import copy


#X = str(input()).split()
#a = [int(x) for x in input().split()]


ABCXY = str(input()).split()
A = int(ABCXY[0])
B = int(ABCXY[1])
C = int(ABCXY[2])
X = int(ABCXY[3])
Y = int(ABCXY[4])
ans1 = 0
ans2 = 0
ans3 = 0

XY = X

ans3=C*2*Y + A*(X-Y)

if(X<Y):
  XY = Y
  ans3 = C*2*X + B*(Y-X)


ans1 = A*X+B*Y
ans2 = C*2*XY

ans = min(ans1,ans2)
ans = min(ans,ans3)


print(ans)

Submission status: Accepted

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

prices = []
if X > Y:
    half_max_count = X + 1
else:
    half_max_count = Y + 1

# 3 for文はダメなので削減する
# sliceで半分にできる多分。
for i in range(0, half_max_count):
    a_price = int(X - i) * A if (int(X - i) >= 0) else 0
    b_price = int(Y - i) * B if (int(Y - i) >= 0) else 0
    half_price = 2 * i * C
    price = half_price + a_price + b_price
    prices.append(price)
print(min(prices))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(500000)

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

cnt_A = max(X, Y)
cnt_B = max(X, Y)

ans = 10**9 + 1

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

print(ans)

Submission status: Accepted

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


    
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
# Code for C - Half and Half
# Use input() to fetch data from STDIN
[a, b, c, x, y] = [int(x) for x in input().split()]

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

print(min(s))

Submission status: Accepted

Solution code:
# Code for C - Half and Half
# Use input() to fetch data from STDIN
[a, b, c, x, y] = [int(x) for x in input().split()]

p = max(x, y) * c * 2
m = min(x, y)
q = m * c * 2 + (x - m) * a + (y - m) * b
r = a * x + b * y

print(min(p, q, r))

Submission status: Accepted

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

plan_a = c * (2*x) + max(0, y-x) * b
plan_b = c * (2*y) + max(0, x-y) * a
plan_c = a * x + b * y

print(min(plan_a, plan_b, plan_c))

Submission status: Accepted

Solution code:

def main():

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


    
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
#n = int(input())
a,b,c,x,y = map(int,input().split())
#a_L = list(map(int,input().split()))
price = float("inf")
for i in range(10**7):
    price = min(price,i*2*c + max(0,x-i)*a +  max(0,y-i)*b)

print(price)

Submission status: Accepted

Solution code:
#n = int(input())
a,b,c,x,y = map(int,input().split())
#a_L = list(map(int,input().split()))
price = 10**16
for i in range(10**7):
    price = min(price,i*2*c + max(0,x-i)*a +  max(0,y-i)*b)

print(price)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#C - Half and Half
#いつもの
a,b,c,x,y = list(map(int,input().split()))
#共通部分の枚数入れ
common = 0
#回答
ans = 0
#共通する部分をABピザの分割にするかどうかを判定する
if(x < y):
    common = x
else:
    common = y
if(c*2 < a+b):
    ans += c*2*common
else:
    ans += (a+b)*common
#どちらか片方多い部分をABピザの分割で買うかAもしくはB単品で買うか判定する
if(x < y):
    if(b < c*2):
        ans += b * (y-common)
    else:
        ans += c*2 * (y-common)
else:
    if(a < c*2):
        ans += a * (x-common)
    else:
        ans += c*2 * (x-common)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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