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:
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
from collections import defaultdict
from collections import deque
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()

#####Shorten#####
def DD(arg): return defaultdict(arg)


#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr

#####MakeDivisors######
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#####ChangeBase#####
def base_10_to_n(X, n):
  if X//n:
    return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i])*n**i for i in range(len(str(X))))

#####IntLog#####
def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count

#############
# Main Code #
#############

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

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

Submission status: Accepted

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

answer = sys.maxsize
for i in range(max(X, Y)+1):
  total = i*2*C+A*max(0,X-i)+B*max(0,Y-i)
  answer = min(answer, total)
print(answer)

Submission status: Accepted

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

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

if A < 2 * C and Y < X:
  answer += A * (X - Y)
elif B < 2 * C and X < Y:
  answer += B * (Y - X)
else:
  answer += 2 * C * abs(X - Y)

print(answer)

Submission status: Accepted

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

print(min(i * 2 * C + max(0, X - i) * A + max(0, Y - i) * B for i in range(10 ** 5 + 1)))

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

p1 = X *A +Y *B

p2 = 2 * max(X,Y) * C

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

print(min(p1,p2,p3))

Submission status: Accepted

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

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

Submission status: Accepted

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

plan1 = (A*X) + (B*Y)
plan2 = (C*2) * max(X,Y)
plan3 = (C*2) * X + B*(Y-X)
plan4 = (C*2) * Y + A*(X-Y)

if X <= Y:
  print(min(plan1,plan2,plan3))
else:
  print(min(plan1,plan2,plan4))

Submission status: Accepted

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

print(v)

Submission status: Accepted

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

# ans = float('inf')

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

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

Submission status: Accepted

Solution code:
# import math
# import itertools
# from collections import deque
# from collections import defaultdict
# import heapq
# import sys
# import bisect
# import numpy as np
# from scipy.special import comb


INF = 1001001001001


def main():

    A, B, C, X, Y = map(int, input().split())
    ab_max = 2 * max(X, Y)

    ans = INF
    for i in range(0, ab_max + 1, 2):
        a_num = max(0, X - i // 2)
        b_num = max(0, Y - i // 2)
        price = A * a_num + B * b_num + C * i
        #print(a_num, b_num, i, price)
        ans = min(ans, price)

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

ans = float('inf')

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

Submission status: Accepted

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

ans = 10 ** 12
for i in range(10 ** 5 + 1):#2 * i枚のABピザを購入
  money = 2 * i * C
  money += A * max(0, X - i)
  money += B * max(0, Y - i)
  ans = min(ans, money)
  
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A, B, C, X, Y = map(int, input().split())
# X >= Yとしたい。
if X < Y:
  A, B = B, A
  X, Y = Y, X
else:
  pass
if A + B <= 2 * C:
  print(A * X + B * Y)
else:
    if A >= 2 * C:
      print(C * 2 * X)
    else:
      print(A * (X - Y) + C * 2 * Y)

Submission status: Accepted

Solution code:
a, b, c, x, y = map(int, input().split())
if x > y:
    x, y = y, x
    a, b = b, a
i = 0
total = a*(x-i) + (y-i)*b + 2*i*c
while True:
    # 1枚ずつ変えていく
    i += 1
    ntotal = a*max(0 ,x-i) + b*max(0, (y-i)) + 2*i*c
    if total < ntotal:
        break
    total = ntotal
print(total)

Submission status: Accepted

Solution code:
def main():
    A, B, C, X, Y = list(map(int, input().split(' ')))
    p1 = A * X + B * Y
    p2 = 2 * C * X + B * max([0, Y - X])
    p3 = 2 * C * Y + A * max([0, X - Y])
    p4 = 2 * C * max([X, Y])
    print(min([p1, p2, p3, p4]))


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
## C - Half and Half
import math
A, B, C, X, Y = map(int, input().split())
money = []
for i in range(0, max(X,Y) + 1 ):
    val = 0
    val += A * (X - i) if X - i > 0 else 0
    val += B * (Y - i) if Y - i > 0 else 0
    money.append(  val + C * 2*i )
print(min(money))

Submission status: Accepted

Solution code:
a, b, c, x, y = map(int, input().split())
m = 0
l = 2 * c * max(x, y)
d = abs(x - y)

if c * 2 <= a + b:
    m += 2 * c * min(x, y)
    if x <= y:
        m += b * d
    else:
        m += a * d
    print(min(m, l))
else:
    m += a * x + b * y
    print(m)

Submission status: Accepted

Solution code:
def half_and_half(a,b,c,x,y):
    z = x   if x > y else y
    can = []
    
    for n in range(z+1):
        p = x - n if x > n else 0
        q = y - n if y > n else 0
        amount = p*a + q*b + n*c*2
        #print("%d = %d x %d + %d x %d + %d x %d " %(amount,p,a,q,b,n,c))
        can.append(amount)

    return min(can)

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

Submission status: Accepted

Solution code:
def half_and_half(a,b,c,x,y):
    z = x   if x > y else y
    can = []
    
    for n in range(z+1):
        p = x - n if x > n else 0
        q = y - n if y > n else 0
        amount = p*a + q*b + n*c*2
        #print("%d = %d x %d + %d x %d + %d x %d " %(amount,p,a,q,b,n,c))
        can.append(amount)

    #print(sorted(can,reverse=True))
    print(min(can))
    #print('')
if __name__ == '__main__':
    a,b,c,x,y = map(int,input().split())
    #a,b,c,x,y = 1500,2000,1600,3,2
    #print(a,b,c,x,y)
    half_and_half(a,b,c,x,y)

Submission status: Accepted

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

min_price = A * X + B * Y

if A + B > 2 * C:
    while X > 0 and Y > 0:
        X = X - 1
        Y = Y - 1
        min_price -= A + B - 2 * C

if X > 0 and A > 2 * C:
    while X > 0:
        X = X - 1
        min_price -= A - 2 * C

if Y > 0 and B > 2 * C:
    while Y > 0:
        Y = Y - 1
        min_price -= B - 2 * C

print(min_price)

Submission status: Accepted

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

min_price = A * X + B * Y

if A + B > 2 * C:
    while X > 0 and Y > 0:
        X = X - 1
        Y = Y - 1
        min_price -= A + B - 2 * C

if X > 0 and A > 2 * C:
    while X > 0:
        X = X - 1
        min_price -= A - 2 * C

if Y > 0 and B > 2 * C:
    while Y > 0:
        Y = Y - 1
        min_price -= B - 2 * C

print(min_price)

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

cost = 1e+15
for i in range(max(x, y)+1):
  xx = max(0, x - i)
  yy = max(0, y - i)
  cost = min(cost, A * xx + B * yy + 2*C*i)
print(cost)

Submission status: Accepted

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

ans=10**9
for i in range(0,max(x,y)*2+2,2):
  tx=max(x-i//2,0)
  ty=max(y-i//2,0)
  t_ans=tx*a+ty*b+i*c
  ans=min(ans,t_ans)
print(ans)

Submission status: Accepted

Solution code:
def main():
  A, B, C, X, Y = map(int, input().split())
  print(min([C*max(X, Y)*2, A*X + B*Y, 2*C*Y+A*(max(0, X-Y)), 2*C*X + B*(max(0, Y-X))]))
if __name__ == "__main__":
  main()

Submission status: Accepted

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

Submission status: Accepted

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

List=[(A*X)+(B*Y)]

AB=0
AP=0
BP=0
ANS=0
while 1:
    if AP>=X and BP>=Y:
        #print(ANS)
        List.append(ANS)
        break
    if AB==2:
        AP+=1
        BP+=1
        AB=0
    else:
        ANS+=C
        AB+=1

AB=0
AP=X
BP=Y
ANS=0
while 1:
    if AP==0:
        ANS+=(BP*B)
        List.append(ANS)
        break
    elif BP==0:
        ANS+=(AP*A)
        List.append(ANS)
        break
    else:
        if AB==2:
            AP-=1
            BP-=1
            AB=0
        else:
            ANS+=C
            AB+=1
            
#print(List)
print(min(List))

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
a,b,c,x,y=map(int,input().split())
ans=2*(max(x,y))*c
temp=0
for i in range(0,2*(max(x,y))+1):#iはABピザの個数。
    if i>=2*x:#いまaピザの個数条件しかかしてないのでこのときbピザが十分存在している時を考慮しないとおかしくなる。
        temp=max(0,(y-(i//2))*b)+i*c
        if temp<=ans:
            ans=temp
    elif i>=2*y:
        temp=max(0,(x-(i//2)))*a+i*c
        if temp<=ans:
            ans=temp
    else:#いまa,bどちらとも不十分の時はまだ場合分けされていない点に留意。
        temp=(x-i//2)*a+(y-i//2)*b+i*c
        if temp<=ans:
            ans=temp
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):
    t=a*max(0,x-i)+b*max(0,y-i)+2*c*i
    ans=min(ans,t)
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):
    total = A*(X-min(X,i)) + B*(Y-min(Y,i)) + C*2*i

    if ans > total:
        ans = total

print(ans)

Submission status: Accepted

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

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(c_max+1):
  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:
#!/usr/bin/env python3
a, b, c, x, y = map(int, input().split())
ans = a * x + b * y
for i in range(1, max(x, y) + 1):
    d = a * max(0, (x - i)) + b * max(0, (y - i)) + (c * 2) * i
    ans = min(ans, d)
print(ans)

Submission status: Accepted

Solution code:

# -*- coding: utf-8 -*-
a,b,ab,x,y = list(map(int, input().split()))
# A、Bそれぞれをそのまま買ったときのコスト
cost=a*x + b*y
# ABだけで済ませた場合のコスト
for i in range(0, max(x, y)+1):
    cost = min(cost, a*max((x-i),0) + b*max((y-i),0) + ab*2*i)

print(cost)

Submission status: Accepted

Solution code:
a,b,c,x,y=map(int,input().split())
l=sorted([a,b,c*2])
if l[0]==c*2:
    print(max(x,y)*c*2)
elif l[1]==c*2:
    if l[0]==a:
        print(y*c*2+max((x-y),0)*a)
    else:
        print(x*c*2+max((y-x),0)*b)
else:
    if a+b>=c*2:
        if x>=y:
            print(y*2*c+(x-y)*a)
        else:
            print(x*2*c+(y-x)*b)
    else:
        print(x*a+y*b)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import math
ans = float('inf')
a,b,c,x,y = map(int,sys.stdin.readline().rstrip().split())
for i in range(max(x,y)+1):
  if x > y and i >= y:
  	sum = a * (x - i) +  2 * i * c
  elif y > x and i >= x:
    sum = b * (y - i) + 2 * i * c
  else:
    sum = a * (x - i) + b * (y - i) + 2 * i * c
  ans = min(ans,sum)
print(ans)

Submission status: Accepted

Solution code:
import math
import copy
from queue import Queue
import heapq
import numpy as np

MOD = 5000000007

#n = int(input())
#b = int(input())
a, b, c, x, y = [int(i) for i in input().split()]
#table = [[int(i)  for i in input().split()] for j in range(m)]
#table = [list(input()) for n in range(r)] #table[h][w]
#p = [int(i) for i in input().split()]
#s = [int(i) for i in range(n)]
#p = [int(input()) for i in range(m)]
#s = input()

#list = list(s)
#dp = [MOD for _ in range(m)]
#dp = [[0 for _ in range(n+1)] for _ in range(n+1)]
#dp = [[[0 for _ in range(11)] for _ in range(2)] for _ in range(11)]

#Combination = [[0 for _ in range(n+1)] for _ in range(n+1)]
#b = [[0 for _ in range(n+1)] for _ in range(n+1)]

kotae = 1000000001
if (x > y):
    max = x
else:
    max = y
for i in range(0,max+1):
    j = x - i
    k = y - i
    if(j < 0):
        j = 0
    if(k < 0):
        k = 0
    temp = a * j + b * k + 2 * c * i
    if (temp < kotae):
        kotae = temp

print(kotae)

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
res = a*x +b*y
for i in range(x):
  p_res = res
  res += 2*c-(a+b)
  if p_res<res:
    res = p_res
    break
for i in range(y-x):
  p_res = res
  res += 2*c-b
  if p_res < res:
    res = p_res
    break
print(res)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
[a, b, ab, x, y] = [int(i) for i in input().split()]
price = []
price.append(a * x + b * y)
if x > y:
    price.append(2 * ab * y + a * (x-y))
else:
    price.append(2 * ab * x + b * (y-x))
price.append(ab * 2 * max(x, y))
print(min(price))

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
import sys

def main():
    A, B, C, X, Y = map(int, sys.stdin.readline().split())
    
    # 
    if C*2 >= A+B:
        ans = A*X + B*Y
    else:
        ans = min(X, Y) * C * 2
        # X: X - min(X, Y)
        # Y: Y - min(X< Y)
        ans += min(A*(X-min(X, Y)), C*2*(X-min(X, Y))) + min(B*(Y-min(X, Y)), C*2*(Y-min(X, Y)))
    print(ans)
    
if __name__ == "__main__":
    main()

Submission status: Accepted

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

ans = 0

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

ans = 10**9
for i in range(10**5+1):
    tmp = 2*c*i + max((x-i), 0)*a + max((y-i), 0)*b
    if x < i and y < i:
            break
    ans = min(ans, tmp)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def resolve():
	a, b, c, x, y = map(int, input().split())
	opt1 = a*x + b*y
	v = a if x > y else b
	opt2 = min(x, y) * 2 * c + abs(x - y)*v
	opt3 = min(x, y)*2*c + abs(x-y)*2*c
	print(min([opt1, opt2, opt3]))
resolve()

Submission status: Accepted

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

cost = 10**9
for i in range(2*10**5+1):
    if i%2==0:
        a_num = X-int(0.5*i)
        b_num = Y-int(0.5*i)
        if a_num < 0 and b_num < 0:
            break
        cost = min(cost, A*max(a_num, 0)+B*max(b_num, 0)+C*i)

print(cost)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A, B, C, X, Y = map(int, input().split())
ans = A * X + B * Y
M = max(X, Y)
N = min(X, Y)
if A + B > C * 2:
    ans -= N * (A + B) - 2 * C * N
    if A > 2 * C and X > Y:
        ans = 2 * C * X
    elif B > 2 * C and X < Y:
        ans = 2 * C * Y
print(ans)

Submission status: Accepted

Solution code:
from collections import Counter

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

if a+b >= ab*2:
    if x < y:
        less, more = x, y
        cost_l, cost_m = a, b
    else:
        less, more = y, x
        cost_l, cost_m = b, a
    
    cost = less*ab*2
    more -= less
    less = 0

    if cost_m < ab * 2:
        cost += more*cost_m
    else:
        cost += more*ab*2

    print(cost)
else:
    print(a*x+b*y)

Submission status: Accepted

Solution code:
from collections import Counter

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

if a+b >= ab*2:
    less = more = 0
    cost_l = cost_m = 0
    if x < y:
        less, more = x, y
        cost_l, cost_m = a, b
    else:
        less, more = y, x
        cost_l, cost_m = b, a
    
    cost = less*ab*2
    more -= less
    less = 0

    if cost_m < ab * 2:
        cost += more*cost_m
    else:
        cost += more*ab*2

    print(cost)
else:
    print(a*x+b*y)

Submission status: Accepted

Solution code:
# coding: utf-8
# hello worldと表示する
#dpでできないかな？
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

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

Submission status: Accepted

Solution code:
a,b,c,x,y=map(int,input().split())
ans=1000000000
for i in range (0,(max(x,y)*2+1),2):#abピザを何枚買ったか考える。偶数枚しかありえないことに注意
  price=c*i+a*(max(0,(x-int(i/2))))+b*(max(0,(y-int(i/2))))
  ans =min(price,ans)
  #abピザの枚数が決まると残りは単品による購入となるので、
  #自動的に購入枚数は決定する。O(n)全探索で済むので間に合う。
  
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

is_ab = ((A+B)/2) >= C

amount = 0

if is_ab:
    amount += 2*C*min(X, Y)
    tmp = min(X, Y)
    X -= tmp
    Y -= tmp
    
    if X>0:
        if A>(2*C):
            amount += 2*C*X
        else:
            amount += A*X
    
    else:
        if B>(2*C):
            amount += 2*C*Y
        else:
            amount += B*Y

else:
    amount += (A*X+B*Y)

print(amount)

Submission status: Accepted

Solution code:
a,b,c,x,y=map(int,input().split())
ans1=x*a+y*b
if x>=y:
    ans2=2*y*c+(x-y)*a#(x,y)=(3,2)であればABを4枚買う
else:
    ans2=2*x*c+(y-x)*b
ans3=2*max(x,y)*c
print(min(ans1,ans2,ans3))

Submission status: Accepted

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

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

Submission status: Accepted

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

AV = (A + B) / 2

cost = 0

if AB <= AV:
    n = min(X, Y)
    cost += AB * n * 2
else:
    n = min(X, Y)
    cost += (A + B) * n

X -= n
Y -= n

if X > 0:
    if 2 * AB <= A:
        cost += 2 * AB * X
    else:
        cost += A * X
elif Y > 0:
    if 2 * AB <= B:
        cost += 2 * AB * Y
    else:
        cost += B * Y

print(cost)

Submission status: Accepted

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

ans = 5000 * 2 * (10**10)
for i in range((10 ** 5) + 1):
    check = 2*c*i + max(x-i,0)*a + max(y-i,0)*b
    if(ans > check):
        ans = check
print(ans)

Submission status: Accepted

Solution code:
A, B, C, X, Y = map(int, input().split())
res = float('Inf')
for Z in range(10**5+1):
    total = 2*Z*C + max(0, X - Z)*A + max(0, Y - Z)*B
    if res > total:
        res = total
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)
elif max(a, b) <= 2 * c:
  m = min(x, y)
  print(2 * c * m + a * (x - m) + b * (y - m))
elif a <= 2 * c:
  print(2 * c * y + a * max(0, x - y))
elif b <= 2 * c:
  print(2 * c * x + b * max(0, y - x))
else:
  print(2 * c * max(x, y))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#ABC095C 全列挙
def main():
    import sys, math
    A,B,C,X,Y = map(int, sys.stdin.readline().split())
    ans = float('inf')
    for i in range(10**5+1):
        tmp = i*2*C + max(0, (X-i)*A) + max(0, (Y-i)*B)
        ans = min(tmp, ans)
        if i > X and i > Y:
            break
    print(ans)  

if __name__=='__main__':
    main()

Submission status: Accepted

Solution code:
#ABC095C
def main():
    import sys, math
    A,B,C,X,Y = map(int, sys.stdin.readline().split())
    L =[]
    #全部C
    L.append(max(X, Y)*2*C)
    
    #できるだけC 不足分A,B
    if X <= Y:
        L +=[X*2*C + (Y-X)*B]
    else:
        L +=[Y*2*C + (X-Y)*A]
    
    #全部A,B
    L.append(A*X+B*Y)
    print(min(L))


if __name__=='__main__':
    main()

Submission status: Accepted

Solution code:
a,b,c,X,Y=map(int,input().split())

s=min(X,Y)
t=max(X,Y)

ans1=2*c*s+a*(X-s)+b*(Y-s)
ans2=a*X+b*Y
ans3=2*c*t

print(min(ans1,ans2,ans3))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A, B, C, X, Y = map(int,input().split())
import math
price_min = -1
for ab in [0, 2*X, 2*Y]:
    X_need = X - 0.5*ab
    Y_need = Y - 0.5*ab
    if X_need < 0:
        X_need = 0
    if Y_need < 0:
        Y_need = 0
    price = ab * C + A * math.ceil(X_need) + B * math.ceil(Y_need)
    if price_min == -1:
        price_min = price
    else:
        price_min = min(price, price_min)
print(price_min)

Submission status: Accepted

Solution code:
import math

A,B,C,X,Y=map(int,input().split())
limit=max(2*X,2*Y)

ans=float('inf')
#L=[]
for i in range(limit+1):
    temp=C*i+A*math.ceil(max(0,X-i/2))+B*math.ceil(max(0,Y-i/2))
    #L.append(temp)
    ans=min(ans,temp)

print(ans)
#print(L)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def solve(A, B, C, X, Y):
    ret = float("inf")
    for a_num in range(X + 1):
        ab_num = 2 * (X - a_num)
        price = min(
            a_num * A + max(0, Y - ab_num // 2) * B + ab_num * C,
            a_num * A + max(ab_num, 2 * Y) * C
        )
        ret = min(ret,price)
    return ret

if __name__ == "__main__":
    A, B, C, X, Y = map(int, 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**10
for i in range(10**5+1):
    ans = min(ans, A*max(X-i, 0) + B*max(Y-i, 0) + 2*C*i)
print(ans)

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:
    ab_cnt = min(x,y)
    remain_a = x-ab_cnt
    remain_b = y-ab_cnt


    if remain_a > 0 and a > 2*c:
        print(ab_cnt*2*c + remain_a*2*c)
    elif remain_b > 0 and b > 2*c:
        print(ab_cnt*2*c + remain_b*2*c)
    else:
        print(ab_cnt*2*c + remain_a*a + remain_b*b)