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:
def main():
    A, B, C, X, Y = map(int, input().split())

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

    print(min(A*X+B*Y, tmp))


if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
a,b,c,x,y=map(int,input().split())
a_b_all=a*x+b*y
ab_all=(c*2)*max(x,y)
mix_a_all=(c*2)*x+b*(y-x)
mix_b_all=(c*2)*y+a*(x-y)
mix_all=max(mix_a_all,mix_b_all)
print(min(a_b_all,ab_all,mix_all))

Submission status: Accepted

Solution code:
def main():
    a, b, c, x, y = map(int, input().split())
    
    t1 = a * x + b * y
    t2 = c * max(x, y) * 2
    if x >= y:
        t3 = c * y * 2 + a * (x - y)
    else:
        t3 = c * x * 2 + b * (y - x)
        
    print(min(t1, t2, t3))
    
    
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(min(X,Y)+1):
    nedan = A*(X-i)+B*(Y-i)+2*i*C
    ans = min(ans,nedan)

print(min(ans,C*(max(2*X,2*Y))))

Submission status: Accepted

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

atob = x*a + y*b

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

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

Submission status: Accepted

Solution code:
import sys
import math
import collections
from collections import deque
from functools import reduce
import heapq
#n = int(input())
a, b, c, x, y = map(int, sys.stdin.readline().split())
#s = input()
#a = list(map(int, sys.stdin.readline().split()))

n = max(x, y)
ans = 10 ** 10
for i in range(n+1):
    p = max(x - i, 0)
    q = max(y - i, 0)
    r = 2 * i * c + p * a + q * b
    if r < ans:
        ans = r

print(ans)

Submission status: Accepted

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

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

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, i * 2 * c + a * max(0, x - i) + b * max(0, y - i))
print(ans)

Submission status: Accepted

Solution code:
import sys
from collections import deque
import copy
def main():
    A, B, C, X, Y = map(int, input().split())
    C *= 2
    ans = 0
    if A + B >= C:
        if X > Y:
            ans = C * Y + min(A, C) * (X - Y)
        else:
            ans = C * X + min(B, C) * (Y - X)
    else:
        if X > Y:
            ans = min(A, C) * (X - Y) + A * Y + B * Y
        else:
            ans = A * X + B * X + min(B, C) * (Y - X)
    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10000000)
import numpy as np
from heapq import heapify, heappop, heappush
import copy
from collections import deque
# queueとして使う場合 push, popleftを使う
from bisect import bisect_left, bisect_right
# bisect_left: 配列の順序関係が崩れない条件で挿入することができる一番左の点
# bisect_right: 配列の順序関係が崩れない条件で挿入することができる一番右の点
# A = [1, 1, 1, 2, 2, 2, 4]
# print(bisect_left(A, 2))  # 3
# print(bisect_right(A, 2))  # 6
# print(bisect_left(A, 3))  # 6
# print(bisect_right(A, 3))  # 6


def main():
    A, B, C, X, Y = map(int,input().split())
    max_C_num = 2 * max(X, Y)
    left_x = X
    left_y = Y
    min_price = 10 ** 10
    for c in range(0, max_C_num + 1, 2):
        left_x = X - c // 2
        left_y = Y - c // 2
        price = C * c
        if price > min_price:
            continue
        if left_x > 0:
            price += A * left_x
        if left_y > 0:
            price += B * left_y
        min_price = min(price, min_price)
    print(min_price)


if __name__ == '__main__':
    main()

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

ans = min([a*x+b*y,
           c*2*y+a*(x-y),
           2*c*x,])

print(ans)

Submission status: Accepted

Solution code:
#多めのピザができてもOK
a,b,c,x,y=map(int,input().split())
if a+b<=2*c:
    print(x*a+y*b)
else:
    if x<=y:
        print(min(2*x*c+(y-x)*b,2*y*c))
    else:
        print(min(2*y*c+(x-y)*a,2*x*c))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

A,B,C,X,Y = list(map(int,input().split()))
max_pizza=max(X,Y)#AピザとBピザのうち、必要な枚数の多い方のピザの枚数
ans=10E+10  

for i in range(0,max_pizza*2+2,2):#ABピザをi枚買う(iは偶数)
    #max_pizza*2+2の「+2」に注意。例えばrange(0,10,2)
    #のとき0,2,4,6,8までしか出てこない。(0,10+2,2)なら10まで出る

    if (X-i/2)<=0 and (Y-i/2)>0:
        ans_kouho = B*(Y-i/2)+C*(i)
    elif (X-i/2)>0 and(Y-i/2)<=0:
        ans_kouho = A*(X-i/2)+C*(i)
    elif (X-i/2)<=0 and(Y-i/2)<=0:
         ans_kouho = C*(i)
    else:
        ans_kouho = A*(X-i/2)+B*(Y-i/2)+C*(i)

    
    if(ans_kouho<ans):
        ans = ans_kouho

print(int(ans))

Submission status: Accepted

Solution code:

A,B,C,X,Y = list(map(int,input().split()))
max_pizza=max(X,Y)#AピザとBピザのうち、必要な枚数の多い方のピザの枚数
ans=10E+10  

for i in range(0,max_pizza*2+2,2):#ABピザをi枚買う(iは偶数)
    
    if (X-i/2)<=0 and (Y-i/2)>0:
        ans_kouho = B*(Y-i/2)+C*(i)
    elif (X-i/2)>0 and(Y-i/2)<=0:
        ans_kouho = A*(X-i/2)+C*(i)
    elif (X-i/2)<=0 and(Y-i/2)<=0:
         ans_kouho = C*(i)
    else:
        ans_kouho = A*(X-i/2)+B*(Y-i/2)+C*(i)

    
    if(ans_kouho<ans):
        ans = ans_kouho

print(int(ans))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


def main():
    A, B, C, X, Y = map(int, input().split())
    M = max(X, Y)
    ans = INF
    for i in range(0, 2 * M + 1, 2):
        tmp = i * C
        rest_a = max(X - i // 2, 0)
        rest_b = max(Y - i // 2, 0)
        tmp += rest_a * A + rest_b * B
        if tmp < ans:
            ans = tmp

    print(ans)


if __name__ == "__main__":
    main()

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

Submission status: Accepted

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

cost_min = 1000000 * 5000
for i in range(2 * max(x, y) + 1):
    cost = c * i
    if x - i // 2 > 0:
        cost += a * (x - i // 2)
    if y - i // 2 > 0:
        cost += b * (y - i // 2)
    cost_min = min(cost, cost_min)
print(cost_min)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b,c,x,y = map(int,input().split())
l = min(x,y)
m = max(x,y)
M = a * x + b * y
for i in range(1,l+1):
  K = a * (x-i) + b * (y-i) + 2 * c * i 
  M = min(M,K)
for i in range(l+1,m+1):
  if x == l:
    K = b * (y-i) + 2 * c * i
  else:
    K = a * (x-i) + 2 * c * i
  M = min(M,K)
print(M)

Submission status: Accepted

Solution code:
a,b,c,x,y = map(int,input().split())
l = min(x,y)
m = max(x,y)
M = a * x + b * y
for i in range(1,l+1):
  K = a * (x-i) + b * (y-i) + 2 * c * i #これだとマイナスになってしまう
  M = min(M,K)
for i in range(l+1,m+1):
  if x == l:
    K = b * (y-i) + 2 * c * i
  else:
    K = a * (x-i) + 2 * c * i
  M = min(M,K)
print(M)

Submission status: Accepted

Solution code:
A,B,C,X,Y = map(int,input().split())
min_xy = min(X,Y)
max_xy = max(X,Y)
ans1 = 2 * C * min_xy + A * (X-min_xy) + B * (Y-min_xy) # 無駄にならない範囲でABピザを買い、残りを買う
ans2 = A*X + B*Y # ABピザを買わない
ans3 = 2 * C * max_xy # ABピザだけを買う
print (min(ans1,ans2,ans3))

Submission status: Accepted

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

ans = float('inf')

for i in range(2 * 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 = float("inf")
for i in range(max(X, Y)+1):
    x = max(X - i, 0)
    y = max(Y - i, 0)
    cost = 2*C * i + A * x + B * y
    ans = min(ans, cost)

print(ans)

Submission status: Accepted

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

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

#AとBのみ
cost1 = a*x + b*y
#ABのみ
cost2 = c*max(x,y)*2
#ABとA
cost3 = c*y*2 + abs(x - y)*a
#ABとB
cost4 = c*x*2 + abs(y-x)*b
ans = min(cost1,cost2)
ans = min(ans,cost3)
ans = min(ans,cost4)
print(ans)

Submission status: Accepted

Solution code:
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60


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

    ans = INF
    for k in range(0, 2 * max(X, Y) + 1, 2):
        i = max(0, X - k // 2)
        j = max(0, Y - k // 2)
        if ans > A * i + B * j + C * k:
            ans = A * i + B * j + C * k

    print(ans)
    return


if __name__ == '__main__':
    main()

Submission status: Accepted

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

import sys
# import time
# import math
# import numpy as np
# import scipy.sparse.csgraph as cs            # csgraph_from_dense(ndarray, null_value=inf), bellman_ford(G, return_predecessors=True), dijkstra, floyd_warshall
# import random                                # random, uniform, randint, randrange, shuffle, sample
# import string                                # ascii_lowercase, ascii_uppercase, ascii_letters, digits, hexdigits
# import re                                    # re.compile(pattern) => ptn obj; p.search(s), p.match(s), p.finditer(s) => match obj; p.sub(after, s)
# from bisect import bisect_left, bisect_right # bisect_left(a, x, lo=0, hi=len(a)) returns i such that all(val<x for val in a[lo:i]) and all(val>-=x for val in a[i:hi]).
# from collections import deque                # deque class. deque(L): dq.append(x), dq.appendleft(x), dq.pop(), dq.popleft(), dq.rotate()
# from collections import defaultdict          # subclass of dict. defaultdict(facroty)
# from collections import Counter              # subclass of dict. Counter(iter): c.elements(), c.most_common(n), c.subtract(iter)
# from datetime import date, datetime          # date.today(), date(year,month,day) => date obj; datetime.now(), datetime(year,month,day,hour,second,microsecond) => datetime obj; subtraction => timedelta obj
# from datetime.datetime import strptime       # strptime('2019/01/01 10:05:20', '%Y/%m/%d/ %H:%M:%S') returns datetime obj
# from datetime import timedelta               # td.days, td.seconds, td.microseconds, td.total_seconds(). abs function is also available.
# from copy import copy, deepcopy              # use deepcopy to copy multi-dimentional matrix without reference
# from functools import reduce                 # reduce(f, iter[, init])
# from functools import lru_cache              # @lrucache ...arguments of functions should be able to be keys of dict (e.g. list is not allowed)
# from heapq import heapify, heappush, heappop # built-in list. heapify(L) changes list in-place to min-heap in O(n), heappush(heapL, x) and heappop(heapL) in O(lgn).
# from heapq import nlargest, nsmallest        # nlargest(n, iter[, key]) returns k-largest-list in O(n+klgn).
# from itertools import count, cycle, repeat   # count(start[,step]), cycle(iter), repeat(elm[,n])
# from itertools import groupby                # [(k, list(g)) for k, g in groupby('000112')] returns [('0',['0','0','0']), ('1',['1','1']), ('2',['2'])]
# from itertools import starmap                # starmap(pow, [[2,5], [3,2]]) returns [32, 9]
# from itertools import product, permutations  # product(iter, repeat=n), permutations(iter[,r])
# from itertools import combinations, combinations_with_replacement
# from itertools import accumulate             # accumulate(iter[, f])
# from operator import itemgetter              # itemgetter(1), itemgetter('key')
# from fractions import gcd                    # for Python 3.4 (previous contest @AtCoder)



def main():
    mod = 1000000007                # 10^9+7
    inf = float('inf')              # sys.float_info.max = 1.79...e+308
    # inf = 2 ** 64 - 1             # (for fast JIT compile in PyPy) 1.84...e+19
    sys.setrecursionlimit(10**6)    # 1000 -> 1000000
    def input(): return sys.stdin.readline().rstrip()
    def ii():    return int(input())
    def mi():    return map(int, input().split())
    def mi_0():  return map(lambda x: int(x)-1, input().split())
    def lmi():   return list(map(int, input().split()))
    def lmi_0(): return list(map(lambda x: int(x)-1, input().split()))
    def li():    return list(input())
    
    
    a, b, c, x, y = mi()
    if x <= y:
        print(min(2 * c * x + (y - x) * b, 2 * c * y, a * x + b * y))
    else:
        print(min(2 * c * y + (x - y) * a,  2 * c * x, a * x + b * y))


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
A,B,C,X,Y=map(int,input().split())
ans=5000*(10**5)*2+1

for i in range(max(X,Y)+1):
  total=0
  total=2*C*i+A*max(X-i,0)+B*max(Y-i,0)
  if ans>=total:
    ans=total
print(ans)

Submission status: Accepted

Solution code:
A,B,C,X,Y=map(int,input().split())
ans=5000*(10**5)*2+1

for i in range(max(X,Y)+1):
  total=0
  total=2*C*i+A*max(X-i,0)+B*max(Y-i,0)
  if ans>=total:
    ans=total
print(ans)

Submission status: Accepted

Solution code:
a, b, c, x, y = map(int, input().split())
price = float("inf")
max_iter = max(x, y)*2

for i in range(max_iter):
    a_num = max(x-i, 0)
    b_num = max(y-i, 0)
    price = min(price, a_num*a + b_num*b + 2*i*c)

print(price)

Submission status: Accepted

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

ans=[]

ans.append(A*X+B*Y)
ans.append(C*max(X,Y)*2)

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

print(min(ans))

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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


min_cost = 0

if X - Y > 0:
    temp_cost = 2 * C * Y
    temp_cost += A * (X - Y)    

    temp_cost2 = 2 * C * X

    if temp_cost > temp_cost2:
        min_cost = temp_cost2
    else:
        min_cost = temp_cost

else:
    temp_cost = 2 * C * X
    temp_cost += B * (Y - X)

    temp_cost2 = 2 * C * Y

    if temp_cost > temp_cost2:
        min_cost = temp_cost2
    else:
        min_cost = temp_cost


temp_cost3 = A * X + B *Y

if temp_cost3 < min_cost:
    min_cost = temp_cost3

print(min_cost)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def printlist(lst, k='\n'): print(k.join(list(map(str, lst))))
INF = float('inf')

def solve():
    a, b, c, x, y = MI()

    ans = 0
    if a + b <= 2 * c:
        mn = min(x, y)
        ans = a * mn + b * mn + max(0, x-mn) * min(a, 2*c) + max(0, y-mn) * min(b, 2*c)

    else:
        mn = min(x, y)
        ans = mn * 2 * c + max(0, x-mn) * min(a, 2*c) + max(0, y-mn) * min(b, 2*c)

    print(ans)



if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def printlist(lst, k='\n'): print(k.join(list(map(str, lst))))
INF = float('inf')

def solve():
    a, b, c, x, y = MI()

    ans = INF
    for k in range(100001):
        yen = 2 * c * k + max(0, x-k) * a + max(0, y-k) * b
        ans = min(ans, yen)
    print(ans)


if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def printlist(lst, k='\n'): print(k.join(list(map(str, lst))))
INF = float('inf')

def solve():
    a, b, c, x, y = MI()

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

        if x < y:
            x = y
            a = b

        if a > 2*c:
            ans += x * 2 * c
        else:
            ans += x * a

    else:
        mn = min(x, y)
        ans = mn * 2 * c
        x -= mn
        y -= mn

        if x < y:
            x = y
            a = b

        if a > 2 * c:
            ans += x * 2 * c
        else:
            ans += x * a

    print(ans)



if __name__ == '__main__':
    solve()

Submission status: Accepted

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

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

Submission status: Accepted

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

if A + B >= AB * 2:
    min_price = min(AB * 2 * min_sheet + A * (X - min_sheet) + B * (Y - min_sheet), AB * 2 * max(X,Y))
else:
    min_price = A * X + B * Y
    
print(min_price)

Submission status: Accepted

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

cost = 0
a_count = 0
b_count = 0

while a_count < x and b_count < y:
    if a + b < 2 * c:
        cost += a + b
        a_count += 1
        b_count += 1
    else:
        cost += 2 * c
        a_count += 1
        b_count += 1

while a_count < x:
    if a < 2 * c:
        cost += a
        a_count += 1
    else:
        cost += 2 * c
        a_count += 1
        b_count += 1

while b_count < y:
    if b < 2 * c:
        cost += b
        b_count += 1
    else:
        cost += 2 * c
        a_count += 1
        b_count += 1

print(cost)

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

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

cost = float('inf')
mz = max(x,y)*2
for z in range(1,mz+1):
    #print(z, (a*x + b*y), a*(x-0.5*z) + b*(y-0.5*z) + c*z)
    if z > 0:
        cost = min(cost, a*max((x-0.5*z),0) + b*max((y-0.5*z),0) + c*z)
cost = int(min(cost, a*x + b*y))
print(cost)

Submission status: Accepted

Solution code:
# Python3 (3.4.3)
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------


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

ans = 0

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

print(ans)

Submission status: Accepted

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


# ABピザをZ枚買ったとする
mcost = 2 ** 30
for i in range(0,200001,2):
    XX = max(0, X - (i // 2))
    YY = max(0,Y - (i // 2))
    cost = XX * A + YY * B + i * C
    if mcost > cost:
        mcost = cost

print(mcost)

Submission status: Accepted

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

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

print(min(k))

Submission status: Accepted

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

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

print(min(l,m,n))

Submission status: Accepted

Solution code:
import math

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

cost_a = min(2*c,a)
cost_b = min(2*c,b)
cost_ab = min(2*c,cost_a+cost_b)
min_xy = min(x,y)

cost_res = 0
if 2*c < a+b:
    cost_res = min_xy * (2*c)
    cost_res += (x-min_xy)*cost_a+(y-min_xy)*cost_b
else:
    cost_res = min_xy * (a+b)
    cost_res += (x-min_xy)*cost_a+(y-min_xy)*cost_b
print(cost_res)

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

Submission status: Accepted

Solution code:
a, b, c, x, y = map(int, input().split())
# 3通り
# 1: ax+by
# 2: 2c*large
# 3: 2c*small + (a/b) * diff

tar1 = a * x + b * y
tar2 = 2 * c * max(x, y)

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


ans = min(tar1, tar2, tar3)


# ---------
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

ans=[A*X+B*Y,2*C*max(X,Y),2*Y*C+A*max(0,X-Y),2*X*C+B*max(0,Y-X)]
print(min(ans))

Submission status: Accepted

Solution code:
# For taking integer inputs.
def inp():
    return(int(input()))


# For taking List inputs.
def inlist():
    return(list(map(int, input().split())))


# For taking string inputs. Actually it returns a List of Characters, instead of a string, which is easier to use in Python, because in Python, Strings are Immutable.
def instr():
    s = input()
    return(list(s[:len(s)]))


# For taking space seperated integer variable inputs.
def invr():
    return(map(int, input().split()))


def which(a, b, x, y):
    if x < y:
        return b
    return a


a, b, c, x, y = invr()

cost1 = a * x + b * y
cost2 = 1000000000000
cost3 = 1000000000000

if x > y:
    temp1 = 2 * x * c
    temp2 = 2 * y * c + (x-y)*a  # baki a damer pizza
    cost2 = min(temp1, temp2)
else:
    temp1 = 2 * y * c
    temp2 = 2 * x * c + (y-x) * b  # baki je koyta y pizza lagbe tar dam
    cost2 = min(temp1, temp2)


print(min(cost1, cost2))

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline

def main():
    ans = []
    A, B, C, X, Y = map(int, input().split())
    for i in range(10**5+1):
        ans.append((C*2*i) + (A*max(0, X-i)) + (B*max(0, Y-i)))

    print(min(ans))

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

if x > y:
  dai = a
else:
  dai = b
  
if dai >= 2 * c:
  print(c * max(x, y) * 2)

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

Submission status: Accepted

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

Submission status: Accepted

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

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):
  ab=i*2
  abc=ab*c+a*max(0,x-i)+b*max(0,y-i)
  ans = min(ans,abc)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a, b, c, x, y = [int(s) for s in input().split()]
ans = 10 ** 9
for i in range(max(x, y) + 1):
    ans_temp = c * 2 * i + a * max(x - i, 0) + b * max(y - i, 0)
    if ans_temp < ans:
        ans = ans_temp
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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


mm=min(x,y)

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