Problem:


Score : 300 points

Problem Statement

"Pizza At", a fast food chain, offers three kinds of pizza: "A-pizza", "B-pizza" and "AB-pizza". A-pizza and B-pizza are completely different pizzas, and AB-pizza is one half of A-pizza and one half of B-pizza combined together. The prices of one A-pizza, B-pizza and AB-pizza are A yen, B yen and C yen (yen is the currency of Japan), respectively.

Nakahashi needs to prepare X A-pizzas and Y B-pizzas for a party tonight. He can only obtain these pizzas by directly buying A-pizzas and B-pizzas, or buying two AB-pizzas and then rearrange them into one A-pizza and one B-pizza. At least how much money does he need for this? It is fine to have more pizzas than necessary by rearranging pizzas.

Constraints

1 ≤ A, B, C ≤ 5000

1 ≤ X, Y ≤ 10^5

All values in input are integers.

Input

Input is given from Standard Input in the following format:

A B C X Y

Output

Print the minimum amount of money required to prepare X A-pizzas and Y B-pizzas.

Sample Input 1

1500 2000 1600 3 2

Sample Output 1

7900

It is optimal to buy four AB-pizzas and rearrange them into two A-pizzas and two B-pizzas, then buy additional one A-pizza.

Sample Input 2

1500 2000 1900 3 2

Sample Output 2

8500

It is optimal to directly buy three A-pizzas and two B-pizzas.

Sample Input 3

1500 2000 500 90000 100000

Sample Output 3

100000000

It is optimal to buy 200000 AB-pizzas and rearrange them into 100000 A-pizzas and 100000 B-pizzas. We will have 10000 more A-pizzas than necessary, but that is fine.



Sample input:
1500 2000 1600 3 2


Sample output:
7900

Submission status: Accepted

Solution code:
a,b,c,x,y=map(int,input().split())
ans=a*x+b*y
if x>y:
    p=2*y*c+(x-y)*min(a,2*c)
    ans=min(ans,p)
if x<=y:
    p=2*x*c+(y-x)*min(b,2*c)
    ans=min(ans,p)
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 * x * 2 + b * (y - x)
else:
    res2 = c * y * 2 + a * (x - y)

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

res = min(res1, res2, res3)
print(res)

Submission status: Accepted

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

Submission status: Accepted

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

    all_double = 2 * max(X, Y) * C
    double = 2 * Y * C + (X - Y) * A if X >= Y else 2 * X * C + (Y - X) * B
    single = X * A + Y * B
    print(min(all_double, double, single))


if __name__ == '__main__':
    main()

Submission status: Accepted

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

price1 = A * X + B * Y
price2 = min(X, Y) * 2 * C + abs(X - Y) * (A if X > Y else B)
price3 = max(X, Y) * 2 * C

print(min(price1, price2, price3))

Submission status: Accepted

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

    if a + b >= 2 * c:
        number = min(x, y)
        x -= number
        y -= number
        minimum += 2 * c * number

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

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

    print(minimum)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys, bisect, math, itertools, string, queue, copy
import numpy as np
import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

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

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

print(ans)

Submission status: Accepted

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

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

ans = min(a*x+b*y, c*max(x, y)*2, tmp)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

p = 0

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

print(min(z1, z2, z3))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys


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

    K = max(X, Y) * 2  # 全部ハーフピザで注文する場合

    cost = 5000 * 10**6
    for i in range(K + 1):

        # 不足枚数
        rest_X = max(X - i // 2, 0)
        rest_Y = max(Y - i // 2, 0)

        # 金額を計算し、最小値を求める
        cost = min(rest_X * A + rest_Y * B + i * C, cost)

    print(cost)


main()

Submission status: Accepted

Solution code:
A, B, C, X, Y = map(int, input().split())
cntA = 0
cntB = 0
cntC = 0
value = 0
if 2*C<=A+B:
    #Cで買いそろえた方が安いので
    #(max(X, Y)-abs(X-Y))*2枚は買うことになる
    Cmaisu = (max(X, Y)-abs(X-Y))*2
    value += C * Cmaisu
    if (2*C<=A and X>Y) or (2*C<=B and X<Y):
        #abs(X-Y)枚についても2Cが安けりゃCで買う
        value += C * abs(X-Y) * 2
    else:
        if X>Y:
            value += A*(X-Y)
        else:
            value += B*(Y-X)
else:
    value += A*X+B*Y
print(value)

Submission status: Accepted

Solution code:
a,b,c,x,y = map(int,input().split())
cost = 0
mincost = 100000*5000*10

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

Submission status: Accepted

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

if a + b < 2 * ab:
    print(a * x + b * y)

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

    print(ans)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

C*=2

tmp = max([X,Y])
result = 1e10
for i in range(tmp+1):
    current = C*i+max([0,A*(X-i)])+max([0, B*(Y-i)])
    if result>current:
        result = current
print(result)

Submission status: Accepted

Solution code:
#
# abc095 c
#

import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """1500 2000 1600 3 2"""
        output = """7900"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """1500 2000 1900 3 2"""
        output = """8500"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """1500 2000 500 90000 100000"""
        output = """100000000"""
        self.assertIO(input, output)


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

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


if __name__ == "__main__":
    # unittest.main()
    resolve()

Submission status: Accepted

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

    min_sum = 100000 * 5000 + 100000 * 5000 + 200000 * 5000

    if a == c and b == c :
        min_sum = a * x + b * y
    elif a  < c and b < c  or a  == c and b  < c or a < c and b  == c :
        min_sum = a * x + b * y
    elif a  > c and b  > c or a  == c and b  > c or a  > c and b  == c  :
        if x >= y :
            min_sum = y * 2 * c
            if a > c * 2:
                min_sum = min_sum + (x - y) * c * 2
            else:
                min_sum = min_sum + (x - y ) * a
        else:
            min_sum = x * 2 * c
            if b > c * 2:
                min_sum = min_sum + (y - x) * c * 2
            else:
                min_sum = min_sum + (y - x ) * b
    elif a < c and b > c:
        if c - a > b - c : #むだ
            min_sum = a * x + b * y
        else:
            if x >= y :
                min_sum = (x-y)* a + y * c * 2
            else:
                min_sum = (y-x)* b + x * c * 2
    elif a > c and b < c:
        if c - b > a - c   : #むだ
            min_sum = a * x + b * y
        else:
            if x >= y :
                min_sum = (x-y)* a + y * c * 2
            else:
                min_sum = (y-x)* b + x * c * 2


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

    print(min_sum)
main()
# if a >= c and b <= c :
#     sum = x * c * 2
#     if x <= y :
#         sum = sum + ( y - x ) * b
# else:
#     sum = y * c * 2
#     if x >= y :
#         sum = sum + ( x - y ) * a


# if b > c * 2 :
    #     b_price = c
    #
    # input_array_list = []
    #
    # while True:
    #     input_array = input().split()
    #     if input_array[0] == "0" and input_array[1] == "0":
    #         break
    #     else:
    #         input_array_list.append(input_array)
    #
    # for item in input_array_list:
    #     n = int(item[0])
    #     k_sum = int(item[1])
    #
    #     count = 0
    #     for i in range(1,n + 1- 2):
    #         for j in range(i+1, n + 1 - 1):
    #             for k in range (j+1, n+ 1):
    #                 if i + j + k == k_sum :
    #                     count = count + 1
    #     print(count)

    #
    # for item in input_array_list:
    #     if item[1] == "+":
    #         print(str(int(item[0])+int(item[2])))
    #     elif item[1] =="-":
    #         print(str(int(item[0])-int(item[2])))
    #     elif item[1] == "/":
    #         print(str(int(item[0])//int(item[2])))
    #     elif item[1] == "*":
    #         print(str(int(item[0])*int(item[2])))
    #

# import sympy as sp

# input_list = []
# a,b,c = map(int, input().split())
# divisors = sp.divisors(c)
#
# count = 0
#
# for divisor in divisors:
#     if a <= divisor and divisor <= b:
#         count = count + 1
# print(count)
#
# while True:
#     pair_str = input().split()
#     pair_int = [int(s) for s in pair_str]
#     if pair_int[0] == 0 and pair_int[1] == 0 :
#         break
#     else:
#         input_list.append(pair_int)
#
# for pair_int in input_list:
#     if pair_int[0] <= pair_int[1]:
#         print("{} {}".format(pair_int[0], pair_int[1]))
#     else:
#         print("{} {}".format(pair_int[1], pair_int[0]))

#for i in range(10000):
#    print("Hello World")
#a = input().split()
#a_int = [int(s) for s in a]
#a_sorted = sorted(a_int)
#print(' '.join(map(str, a_sorted)))

Submission status: Accepted

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

if A+B <= 2*C:
    ans = X*A + Y*B
else:
    z = min(X, Y)
    if z == X:
        c = B
    else:
        c = A
    ans = C*2*z
    Z = max(X, Y) - z
    if c <= 2*C:
        ans += c*Z
    else:
        ans += 2*C*Z
    
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:
        print(2*c*x+min(b,2*c)*abs(y-x))
    else:
        print(2*c*y+min(a,2*c)*abs(y-x))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A,B,C,X,Y  = map(int,input().split())
AB = A*X + B*Y
ans = AB #すべてAとBで

for i in range(max(X,Y)+1):
  c = C * 2*i# 2*i個のCでAとBでを１つづつ
  a = max(0,X-i)*A#不足分Aの代金
  b = max(0,Y-i)*B#不足分B
  ans = min(ans,c+a+b)
print(ans)

Submission status: Accepted

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

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

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

Submission status: Accepted

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

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

numa = 0
numb = 0
numc = max(x, y)*2
value = c*numc

# print(numa, numb, numc, value)

while numc:
    numc_tmp = numc-2
    numa_tmp = max(x-numc_tmp//2, 0)
    numb_tmp = max(y-numc_tmp//2, 0)

    value_tmp = a*numa_tmp+b*numb_tmp+c*numc_tmp
    # print(numa_tmp, numb_tmp, numc_tmp, value_tmp)

    if value_tmp >= value:
        print(value)
        exit()
    numc = numc_tmp
    numa = numa_tmp
    numb = numb_tmp
    value = value_tmp

print(value)

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())
ans = 10**10
for i in range(10**8):
    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())

AB = min(A + B, C * 2)
A = min(A, C * 2)
B = min(B, C * 2)

ans = 0

if X > Y:
    X -= Y
    ans += AB * Y
    ans += A * X
else:
    Y -= X
    ans += AB * X
    ans += B * Y

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
from sys import stdin


def input(): return stdin.readline().rstrip()


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


def ii():
    return int(input())
A, B, C, X, Y = mips()
money = 0
while X > 0 and Y > 0:
    if (A+B) <= 2*C:
        money += (A+B)
        X -= 1
        Y -= 1
    else:
        money += 2*C
        X -= 1
        Y -= 1
while X > 0:
    if A <= 2*C:
        money += A
        X -= 1
    else:
        money += 2*C
        X -= 1
        Y -= 1
while Y > 0:
    if B <= 2*C:
        money += B
        Y -= 1
    else:
        money += 2*C
        X -= 1
        Y -= 1
print(money)

Submission status: Accepted

Solution code:
A, B, C, X, Y = [int(n) for n in input().split(" ")]

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

Submission status: Accepted

Solution code:
A, B, C, X, Y = map(int, input().split())
 
p1 = 2 * C * min(X, Y) + A * (X - min(X, Y)) + B * (Y - min(X, Y))
p2 = 2 * C * max(X, Y)
p3 = A * X + B * Y
print(min(p1, p2, p3))

Submission status: Accepted

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

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

Submission status: Accepted

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

#全部Cで買うとき
a = 2*C*min(X,Y) + 2*C*(max(X,Y)-min(X,Y))

#片方を全部Cで買うとき
if X > Y:
    b = 2*C*Y + (X-Y)*A
elif Y > X:
    b = 2*C*X + (Y-X)*B
else:
    b = a
    
#全部AとBで買うとき
c = A*X + B*Y

print(min(a,b,c))

Submission status: Accepted

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

for i in range(2,all_ab+1,2):
    cnt = i*c
    alt = int(i/2)
    need_a = max(x - alt, 0)
    need_b = max(y - alt, 0)
    cnt += a*need_a + b*need_b
    ans = min(ans, cnt)
    # print(i,ans)

print(ans)

Submission status: Accepted

Solution code:
a, b, c, x, y = map(int, input().split())
ans = 1e9
for i in range(max(x, y) + 1):
	cal = i * c * 2
	if x > i:
		cal += (x - i) * a
	if y > i:
		cal += (y - i) * b
	ans = min(cal, ans)
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

high = max(x, y)
low = min(x, y)

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

Submission status: Accepted

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

max_c = max(2*X, 2*Y)

min_cost = float('inf')
for c in range(0, max_c+1, 2):
  a = max(0, X - c//2)
  b = max(0, Y - c//2)
  cost = A*a + B*b + C*c
  
  if cost < min_cost:
    min_cost = cost
    
    
print(min_cost)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

cost_list = []
for i in range(0, max([X, Y]) * 2 + 1, 2):
    AB_cost = C * i
    A_cost = A * (X - int(i / 2))
    B_cost = B * (Y - int(i / 2))
    if A_cost < 0 and B_cost >= 0:
        A_cost = 0

    elif A_cost >= 0 and B_cost < 0:
        B_cost = 0
    elif A_cost >= 0 and B_cost >= 0:
        pass
    else:
        A_cost = 0
        b_cost = 0
    cost = AB_cost + A_cost + B_cost
    cost_list.append(cost)
#print(cost_list)
print(min(cost_list))

Submission status: Accepted

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

#abピザをab枚使う
ans=float("INF")
for ab in range(0,2*max(x,y)+1,2):
  #使うお金
  #ABピザ
  cnt=ab*c
  #Aピザ
  cnt+=a*max(0,x-ab//2)
  #Bピザ
  cnt+=b*max(0,y-ab//2)
  ans=min(cnt,ans)

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A,B,C,X,Y = map(int,input().split())
min_price = float("inf")
c_count = 0
while True:
    min_price = min(min_price,(A * X) + (B * Y) + (C * c_count))
    if X == 0 and Y == 0:
        break
    X = 0 if X <= 0 else (X-1)
    Y = 0 if Y <= 0 else (Y-1)
    c_count += 2
print(min_price)

Submission status: Accepted

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

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

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

if y > 0:
    if b > c * 2:
        ans += y * c * 2
    else:
        ans += y * b

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
class Pizza:
  def __init__(self, price, count = 0):
    self.price = price
    self.count = count
    
  def count_pay(self):
  	return self.price * self.count
  
  def add_count(self,n):
    self.count += n
    if self.count <= 0:
      self.count = 0
      
A, B, C, X, Y = map(int, input().split())
P_A = Pizza(A,X)
P_B = Pizza(B,Y)
P_AB = Pizza(C)

i = 0
pay_list = []
while i <= max(X, Y):
  pay = P_A.count_pay() + P_B.count_pay() + P_AB.count_pay()
  pay_list.append(pay)
  P_A.add_count(-1)
  P_B.add_count(-1)
  P_AB.add_count(2)
  i += 1

print(min(pay_list))

Submission status: Accepted

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

    ans = 10**10
    for ai in range(x+1):
        ci = (x - ai)*2
        bi = y - ci//2
        if bi<0:
            bi = 0
        cost = a*ai + b*bi + c*ci
        if cost<ans:
            ans = cost

        if ai==0:
            if c*2 < b:
                bi = 0
                ci = max(x, y)*2
                cost = c*ci
                if cost<ans:
                    ans = cost

    print(ans)

if __name__=="__main__":
    main()

Submission status: Accepted

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

if A+B <= 2*C:
  #only buy A and B
  print(X*A+Y*B)

else:
  if X >= Y and A < 2*C:
    #print("A")
    select = A
  elif X < Y and B < 2*C:
    #print("B")
    select = B
  else:
    #print("C")
    select = 2*C
    
  print((min(X,Y)*2*C)+ (abs(X-Y)*select))

Submission status: Accepted

Solution code:
import math
A,B,C,X,Y = map(int,input().split())
ans = A * X + B * Y
for c in range(2 * 10 ** 5 + 1):
    a = math.ceil(X - c * 0.5)
    b = math.ceil(Y - c * 0.5)
    if a < 0:
        a = 0
    if b < 0:
        b = 0
    mny = a * A + b * B + c * C
    if mny < ans:
        ans = mny
print(ans)

Submission status: Accepted

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

a = [0,1,2,X-2,X-1,X,abs(X-Y),abs(X-Y+1),abs(X-Y-1)]
b = [0,1,2,Y-2,Y-1,Y,abs(Y-X),abs(Y-X+1),abs(Y-X-1)]
c = [0,1,2,X*2-2,X*2-1,X*2,Y*2-2,Y*2-1,Y*2]
ans = A * X + B * Y
for aa in a:
    for bb in b:
        for cc in c:
            if aa + cc * 0.5 >= X and bb + cc * 0.5 >= Y:
                mny = A * aa + B * bb + C * cc
                if mny < ans:
                    ans = mny
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b,c,x,y = map(int,input().split())
max_pay = x * a + y * b
i = 0
while (x - i)>=0 or (y - i)>=0:
    pay = max((x - i),0) * a + max((y - i),0) * b + c * i * 2
    #print(pay)
    max_pay = min(max_pay,pay)
    i += 1
print(max_pay)

Submission status: Accepted

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

res = A*X +B*Y

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

Submission status: Accepted

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

Submission status: Accepted

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

ans = 10**20
for i in range(max(X, Y) * 2 + 1):
    c = i
    a = X - i // 2
    if a < 0:
        a = 0
    b = Y - i // 2
    if b < 0:
        b = 0
    v = a * A + b * B + c * C
    if v < ans:
        ans = v

print(ans)

Submission status: Accepted

Solution code:
a,b,c,x,y = map(int,input().split())
c *= 2
ans = 10 ** 16
for i in range(max(x,y) + 1):
    p = 0
    p += c * i
    p += a * (max(0,x - i))
    p += 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())

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
##import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
import heapq
from fractions  import gcd
#input=sys.stdin.readline
#import bisect
a,b,c,x,y=map(int,input().split())
if x<y:
    ans=min((a*x+b*y),2*x*c+b*(y-x),2*y*c)
    
else:
    ans=min((a*x+b*y),2*y*c+a*(x-y),2*x*c)
print(ans)

Submission status: Accepted

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

ans = 10 ** 18
for i in range(0, 2 * max(X, Y) + 1, 2):
    tmpx = X - (i // 2)
    if tmpx <= 0:
        tmpx = 0
    tmpy = Y - (i // 2)
    if tmpy <= 0:
        tmpy = 0
    ans = min(ans, (i * C) + (tmpx * A) + (tmpy * B))

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a, b, c, x, y = map(int, input().split())
if a+b <= c*2:
    print(a*x+b*y)
else:
    ans = 10**9
    for i in range(min(x,y)*2, 1+max(x,y)*2, 2):
        xx = x-i/2 if x-i/2 >= 0 else 0
        yy = y-i/2 if y-i/2 >= 0 else 0
        ans = min(ans, int(a*xx+b*yy+c*i))
    print(ans)

Submission status: Accepted

Solution code:
import sys


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

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

ans = 0

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

print(ans)

Submission status: Accepted

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

ans = 0
# abがお得なパターン
if a + b >= c * 2:
    ans += c * min(x,y) * 2
    nokori = max(x,y) - min(x,y)
    # aが残ったパターン
    if max(x,y) == x:
        # abのがお得
        if a > c*2:
            ans += c * nokori * 2
        else:
            ans += a * nokori
    else:
        if b > c*2:
            ans += c * nokori * 2
        else:
            ans += b * nokori
else:
    ans += a * x + b* y

print(ans)

Submission status: Accepted

Solution code:
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

from functools import lru_cache

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

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

Submission status: Accepted

Solution code:
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

from functools import lru_cache

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

# 4通りしかない

# A, Bをそれぞれ買う
ans = A * X + B * Y

# AB + A or B
if X < Y:
    tmp = X * (2 * C)
    tmp += abs(X - Y) * B
else:
    tmp = Y * (2 * C)
    tmp += abs(X - Y) * A
ans = min(ans, tmp)

# AB
ans = min(ans, max(X, Y) * (2 * C))

print(ans)

Submission status: Accepted

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

c2 = c * 2
itr_end = max(x, y) + 1
results = []

for i in range(0, itr_end):
    # Cを2つi個だけ買って、残りはa、bで買う。ただし、マイナスの時(余っている時)は計算してはいけない。
    result = c2 * i
    if (x - i) > 0:
        result += a * (x - i)
    if (y - i) > 0:
        result += b * (y - i)

    results.append(result)

print(min(results))

Submission status: Accepted

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

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

Submission status: Accepted

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

d = (a + b) - 2 * c

sep = a * x + b * y

ab_x = 2 * x * c
ab_y = 2 * y * c
sum = 0

if d < 0:
    print(sep)
    exit()
elif x > y:
    sum = a * (x - y) + ab_y
    if sum > ab_x:
        print(ab_x)
    else:
        print(sum)
else:
    sum = b * (y - x) + ab_x
    if sum > ab_y:
        print(ab_y)
    else:
        print(sum)