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())
check=2*c-a-b
ans=0
if x>=y:
    if check>=0:
        ans+=(a+b)*y+a*(x-y)
    else:
        ans+=2*c*y+min(a,2*c)*(x-y)
else:
    if check>=0:
        ans+=(a+b)*x+b*(y-x)
    else:
        ans+=2*c*x+min(b,2*c)*(y-x)
print(ans)

Submission status: Accepted

Solution code:
import sys
from collections import Counter
import random
import numpy as np
import time

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

Submission status: Accepted

Solution code:
#import numpy as np
#n = int(input())
ipt = [int(i) for i in input().split()]

a = ipt[0]
b = ipt[1]
c = ipt[2]
x = ipt[3]
y = ipt[4]

a_pizza = x
b_pizza = y
c_pizza = 0
if a+b > 2*c:
    c_pizza = 2*min(a_pizza, b_pizza)
    a_pizza -= c_pizza / 2
    b_pizza -= c_pizza / 2
if a_pizza > 0 and a > 2*c:
    c_pizza += 2*a_pizza
    a_pizza = 0
if b_pizza > 0 and b > 2*c:
    c_pizza += 2*b_pizza
    b_pizza = 0

print(int(a*a_pizza+b*b_pizza+c*c_pizza))

Submission status: Accepted

Solution code:
input_str = input()

A, B, C, X, Y = input_str.split(" ")

A = int(A)
B = int(B)
C = int(C)
X = int(X)
Y = int(Y)

answer = 0
ave_AB = (A + B) / 2
if ave_AB <= C:
    answer = X*A + Y*B
else:
    xy_min = min(X,Y)
    answer = xy_min * C * 2
    tmp = X - Y
    if tmp > 0:
        if A < C*2:
            answer += tmp*A
        else:
            answer += tmp*C*2
    elif tmp < 0:
        if B < C*2:
            answer += -tmp*B
        else:
            answer += -tmp*C*2
print(answer)

Submission status: Accepted

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

ab_set = min(a+b, 2*c)

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

Submission status: Accepted

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**15
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    a,b,c,x,y = LI()
    if a < b:
        a,b = b,a
        x,y = y,x
    r = 0
    if a > c*2:
        r += x * c*2
        y = max(y-x,0)
        x = 0
    if b > c*2:
        r += y * c*2
        y = 0
    if a+b > c*2:
        t = min(x,y)
        r += t * c*2
        x -= t
        y -= t
    r += a * x
    r += b * y


    return r



print(main())

Submission status: Accepted

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

print(min([A*X + B*Y, max(X, Y)*C*2, min(X, Y)*C*2 + abs(X-Y)*(A if Y < X else B)]))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b,c,x,y=map(int, input().split())
okn=0
if(a+b>c*2):
    xy=abs(x-y)
    m=max(x,y)
    z=m-xy
    if(m==x):
        if(a>c*2):
            okn=c*2*x
        else:
            okn+=c*2*z
            okn+=a*xy
    else:
        if(b>c*2):
            okn=c*2*y
        else:
            okn+=c*2*z
            okn+=b*xy
else:
    okn+=a*x+b*y
print(okn)

Submission status: Accepted

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

pizza_num_dict = {'A': 0, 'B': 0}

price_sum = 0
if A >= 2 * C:
    pizza_num_dict['A'] += X
    pizza_num_dict['B'] += X
    price_sum += 2 * X * C
    if X >= Y:
        print(price_sum)
        exit(0)
    else:
        if B >= 2 * C:
            price_sum += 2 * (Y - X) * C
        else:
            price_sum += (Y - X) * B
        print(price_sum)
        exit(0)

elif B >= 2 * C:
    pizza_num_dict['A'] += Y
    pizza_num_dict['B'] += Y
    price_sum += 2 * Y * C
    if Y >= X:
        print(price_sum)
        exit(0)
    else:
        price_sum += (X - Y) * A
        print(price_sum)
        exit(0)

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

Submission status: Accepted

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

ans = 0

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

print(ans)

Submission status: Accepted

Solution code:
X=list(map(int,input().split()))
if X[3]>X[4]:
	X=[X[i] for i in [1,0,2,4,3]]
print(min(X[0]*X[3]+X[1]*X[4], X[1]*X[4]+(2*X[2]-X[1])*X[3], 2*X[2]*X[4]))

Submission status: Accepted

Solution code:
# input -- A B C X Y

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

# can buy '2 * Z' pieces of C-pizza
Z = min(X, Y)
sum_of_pay = 0

if A+B > 2*C:
    sum_of_pay += 2 * Z * C

    if X-Z > 0: # if remain some A-pizza
        if A > 2*C:
            sum_of_pay += 2 * (X-Z) * C
        else:
            sum_of_pay += (X-Z) * A
    else:      # B-pizza
        if B > 2*C:
            sum_of_pay += 2 * (Y-Z) * C
        else:
            sum_of_pay += (Y-Z) * B
else:
    sum_of_pay += (X*A + Y*B)

print(sum_of_pay)

Submission status: Accepted

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

Submission status: Accepted

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

res = 0

if x == y:
    res = min(a * x + b * y, c * x * 2)

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

else:
    res = min(a * x + b * y, b * (y - x) + c * x * 2, c * y * 2)

print(res)

Submission status: Accepted

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

m = 10000000000
for c in range(0, max(X, Y)*2+1, 2):
  a = max(X - c//2, 0) # to buy
  b = max(Y - c//2, 0) # to buy
  m = min(m, a*A + b*B + c*C)
print(m)

Submission status: Accepted

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

Submission status: Accepted

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

if X<Y:
    tmp = A
    A=B
    B=tmp
    tmp =X
    X=Y
    Y=tmp

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

if A>2*C:
    print(2*C*X)
    exit()
print( 2*C*Y + (X-Y)*A)

Submission status: Accepted

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

Submission status: Accepted

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

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

common_price = min(low * (a + b), low * 2 * c)
if x > low:
    diff = x - low
    diff_price = min(a * diff, c * 2 * diff)
elif y > low:
    diff = y - low
    diff_price = min(b * diff, c * 2 * diff)
else:
    diff_price = 0

print common_price + diff_price

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys

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

best_price = sys.maxsize


for i in range(0, max(x, y) * 2 + 1, 2):
    rest_a = x
    rest_b = y

    if i // 2 >= x:
        rest_a = 0
    else:
        rest_a = x - i // 2

    if i // 2 >= y:
        rest_b = 0
    else:
        rest_b = y - i // 2

    price = rest_a * a + rest_b * b + c * i
    if price < best_price:
        best_price = price
    # print("buy a = " + str(rest_a) + ", b = " + str(rest_b) + ", c = " + str(i) + ", price = " + str(price))

print(best_price)

Submission status: Accepted

Solution code:
#!/usr/bin/python2
# -*- coding: utf-8 -*-

import sys

def rl(proc=None):
    if proc is not None:
        return proc(sys.stdin.readline())
    else:
        return sys.stdin.readline().rstrip()

def srl(proc=None):
    if proc is not None:
        return map(proc, rl().split())
    else:
        return rl().split()

def main():
    A, B, C, X, Y = srl(int)
    r = X * A + Y * B
    for i in xrange(2, 2*max(X, Y) + 2, 2):
        r = min(r, i * C + max(0, (X - i/2)) * A + max(0, (Y - i/2)) * B)
    print r


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
a,b,c,x,y=[int(i) for i in raw_input().split()]
if x<=y:
    print min(a*x+b*y,(2*x)*c+(y-x)*b,2*max(x,y)*c)
else:
    print min(a*x+b*y,(2*y)*c+(x-y)*a,2*max(x,y)*c)

Submission status: Accepted

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

# A,B,C,X,Yを取得
a, b, c, x, y = map(int, input().split())

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

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

# 結果を出力
print("{}".format(price))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import re
PIZ=re.split('[ ]', input())
A=int(PIZ[0])
B=int(PIZ[1])
C=int(PIZ[2])
X=int(PIZ[3])
Y=int(PIZ[4])
a=0
b=0
c=0
if(A+B>=C*2):
    if X<=Y:
        for i in range(X):
            X-=1
            Y-=1
            c+=2
    else:
        for i in range(Y):
            X-=1
            Y-=1
            c+=2
    if A<C*2:
        a+=X
    else:
        c+=X*2
    if B<C*2:
        b+=Y
    else:
        c+=Y*2
else:
    for j in range(X):
        X-=1
        a+=1
    for k in range(Y):
        Y-=1
        b+=1
print(A*a+B*b+C*c)

Submission status: Accepted

Solution code:
a, b, c, x, y=map(int, input().split())
m=2*x*c
n=c*y*2+a*(x-y)
d=2*y*c
e=c*x*2+b*(y-x)
f=a*x+b*y
g=min(m,n,f)
h=min(d,e,f)
if x>=y:
    print(g)
else:
    print(h)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys,collections,itertools,re,math,fractions,decimal,random,array,bisect,heapq

# decimal.getcontext().prec = 50
# sys.setrecursionlimit(10000)
# MOD = 10**9 + 7

def solve(f):
    a,b,c,x,y = f.read_int_list()

    ans = float('inf')
    ans = min(ans, a*x+b*y)
    ans = min(ans, max(x,y)*2*c)
    if y > x:
        ans = min(ans, x*2*c+(y-x)*b)
    else:
        ans = min(ans, y*2*c+(x-y)*a)

    return ans


class Reader(object):
    def __init__(self, filename=None):
        self.file = open(filename) if filename is not None else None
        self.case = 1

    def __readline(self):
        return self.file.next().strip() if self.file else raw_input()

    def next_case(self):
        self.file.next()
        self.case += 1

    def read_int(self): return int(self.__readline())
    def read_float(self): return float(self.__readline())
    def read_long(self): return long(self.__readline())
    def read_decimal(self): return decimal.Decimal(self.__readline())
    def read_str(self): return self.__readline()

    def read_int_list(self): return map(int, self.__readline().split())
    def read_float_list(self): return map(float, self.__readline().split())
    def read_long_list(self): return map(long, self.__readline().split())
    def read_decimal_list(self): return map(decimal.Decimal, self.__readline().split())
    def read_str_list(self): return self.__readline().split()

if __name__ == '__main__':
    filename = sys.argv[1] if len(sys.argv) > 1 else None
    f = Reader(filename)
    if f.file:
        while True:
            print "Case #%d\n"%f.case, solve(f)
            try:
                f.next_case()
            except StopIteration:
                break
    else:
        print solve(f)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a, b, c, X, Y = map(int, input().split())
if (2 * c - a -b ) <= 0:
    _z = min(X, Y)
    if X >= Y:
        _x = X - Y
        _y = 0
    else:
        _x = 0
        _y = Y - X
    D = a * _x + b * _y + 2 * c *_z
    E = 2*c * max(X, Y)
    print(min(D, E))
else:
    _z = 0
    _x = X
    _y = Y
    D = a * _x + b * _y + 2 * c *_z
    E = 2*c * max(X, Y)
    print(min(D, E))

Submission status: Accepted

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

if a+b >= 2*c:
    if x >= y:
        if a>=2*c:
            print(2*x*c)
        else:
            print(y*2*c+(x-y)*a)
    else:
        if b>=2*c:
            print(2*y*c)
        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(" "))

def only_plus(n):
    if n < 0:
        return 0
    else:
        return n

anss = []
for i in range(0, 2 * max(x, y) + 1, 2):
    anss.append(c * i + a * only_plus(x - (i // 2)) + b * only_plus(y - (i // 2)))
    
print(min(anss))

Submission status: Accepted

Solution code:
import math, string, fractions, heapq, re, array, bisect, sys, random, time, copy
import itertools as it
import collections as cl
import functools as ft


def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()


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


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

print(result)

Submission status: Accepted

Solution code:
def should_buy_ab(a,b,c):
    return 2 * c <= a + b


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

    if should_buy_ab(a,b,c):
        common = min(x, y)
        paid += (common * 2 * c)
        x -= common
        y -= common

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

    paid += x * a
    paid += y * b

    return paid


a, b, c, x, y = map(int, raw_input().split())
print solve(a,b,c,x,y)

Submission status: Accepted

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

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

if A+B <= 2*C:
  print(A*X + B*Y)
else:
  ab_num = max(X, Y)
  total1 = 2*C*ab_num

  ab_num = min(X, Y)
  a_num  = X - ab_num
  b_num  = Y - ab_num
  total2 = 2*C*ab_num + A*a_num + B*b_num

  if total1 >= total2:
    print(total2)
  else:
    print(total1)

Submission status: Accepted

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

ans = A * X + B * Y
if X >= 1 and Y >= 1:

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

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

print(ans)

Submission status: Accepted

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

line = input().split(" ")
A = int(line[0])
B = int(line[1])
C = int(line[2])
X = int(line[3])
Y = int(line[4])

ret = 99999999999
for a in range(X+1):
    t = a*A
    t += (X-a)*2*C
    if Y-(X-a)>0:
        t += (Y-(X-a))*B

    if t<ret:
        ret = t

for b in range(Y+1):
    t = b*B
    t += (Y-b)*2*C
    if X-(Y-b)>0:
        t += (X-(Y-b))*A

    if t<ret:
        ret = t
print(ret)

Submission status: Accepted

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

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

Submission status: Accepted

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

def money(A, B, C, X, Y):
    
    axby = A*X + B*Y
    if max([A, B, C]) == C:
        return axby
    
    cxy = C*max([X,Y])*2
    if X < Y:
        abcxy = C*X*2 + (Y-X)*B
    else:
        abcxy = C*Y*2 + (X-Y)*A
    
    return min([axby, cxy, abcxy])
  
print(money(A, B, C, X, Y))

Submission status: Accepted

Solution code:
x = list(map(int, input().split()))
if x[0] + x[1] <= x[2] * 2:
    cost = x[0] * x[3] + x[1] * x[4]
else:
    if x[3] > x[4]:
        a = x[3] - x[4]
        b = 0
        ab = x[4] * 2
        if x[0] >= x[2] * 2:
            a = 0
            b = 0
            ab = x[3] * 2
    else:
        a = 0
        b = x[4] - x[3]
        ab = x[3] * 2
        if x[1] >= x[2] * 2:
            a = 0
            b = 0
            ab = x[4] * 2
    cost = x[0] * a + x[1] * b + x[2] * ab
print(cost)

Submission status: Accepted

Solution code:
import numpy as np

A,B,C,X,Y = list(map(int,input().split()))
mnum = min([X,Y])
mval = min([A,B])
absep = A * X + B* Y 
minab = C * mnum  * 2 +  (X - mnum ) * A + (Y - mnum) * B 
allab = C  *  max([X,Y]) * 2

print(min([absep,minab,allab]))

Submission status: Accepted

Solution code:
import sys

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

a = int(a)
b = int(b)
c = int(c)
x = int(x)
y = int(y)

best_price = sys.maxsize

for i in range(0, max(x + 1, y + 1) * 2 + 1, 2):
    rest_a = x
    rest_b = y

    if i // 2 >= x:
        rest_a = 0
    else:
        rest_a = x - i // 2

    if i // 2 >= y:
        rest_b = 0
    else:
        rest_b = y - i // 2

    price = rest_a * a + rest_b * b + c * i
    if price < best_price:
        best_price = price
    # print("buy a = " + str(rest_a) + ", b = " + str(rest_b) + ", c = " + str(i) + ", price = " + str(price))

print(best_price)

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:
    if A < 2 * C and X > Y:
        print(Y * 2 * C + (X - Y) * A)
    elif B < 2 * C and X < Y:
        print(X * 2 * C + (Y - X) * B)
    else:
        print(max(X, Y) * 2 * C)

Submission status: Accepted

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

result = int()
minc = min([x,y])
x_,y_ = map(lambda i: i-minc, [x,y])
    
if a+b > 2*c:
    result = (minc*2) * c
    result += x_ * 2*c if a > 2*c else x_ * a
    result += y_ * 2*c if b > 2*c else y_ * b
else:
    result = a*x + b*y

print result

Submission status: Accepted

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

ans = []
ans.append(x * a + y * b)
if(x < y):
    ans.append(x * 2 * c + (y - x) * b)
else:
    ans.append(y * 2 * c + (x - y) * a)
ans.append(max(x, y) * 2 * c)

print(min(ans))

Submission status: Accepted

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

Submission status: Accepted

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

minp=0
# a,c
tmp=c*y+max(math.ceil((x-y)/2),0)*a
minp =tmp
# b,c
tmp=c*x+max(math.ceil((y-x)/2),0)*b
if minp > tmp:
    minp=tmp

# c
tmp=c*max(x,y)
if minp > tmp:
    minp=tmp
# a, b
tmp=a*math.ceil(x/2)+b*math.ceil(y/2)
if minp > tmp:
    minp=tmp

print(minp)

Submission status: Accepted

Solution code:
#!/usr/bin/env python
a, b, c, x, y = map(int, input().split())
ans = a*x+b*y
for i in range(1, max(x, y)+1):
    if i <= min(x, y):
        ans = min(ans, ans-a-b+2*c)
    else:
        if x < y:
            ans = min(ans, ans-b+2*c)
        else:
            ans = min(ans, ans-a+2*c)
print(ans)

Submission status: Accepted

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

m = min(x, y)
M = max(x, y)
dict = {x: a, y: b}
total_cost = 0
set_cost = min(a + b, 2 * c)

total_cost += m * set_cost

# 残りは M - m 枚をかう。Mに該当する金額は、dict[M]

total_cost += (M - m) * min(dict[M], 2 * c)
print(total_cost)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b,c,x,y = map(int, input().split())
def hoge(n):
    nx = max(0, x-n)
    ny = max(0, y-n)
    return 2*n*c + nx*a+ny*b

ans = 10**10

for i in range(3*10**5):
    ans = min(ans, hoge(i))

print(ans)

Submission status: Accepted

Solution code:
A, B, C, X, Y = map(int, input().split())
cost = 0
if X > Y:
    max_index = A
    M = X
else:
    max_index = B
    M = Y

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

print(cost)

Submission status: Accepted

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

def solve(A, B, C, X, Y):
    if Y > X:
        X, Y = Y, X
        A, B = B, A
    # X > Y
    A0 = 0
    B0 = 0
    r = 0
    if A + B > C * 2:
        r += Y * C * 2
        X -= Y
        Y = 0
    else:
        if B > C * 2:
            r += C * 2 * Y
            X -= Y
            Y = 0
        else:
            r += B * Y
            Y = 0
    if A > C * 2:
        r += C * 2 * X
        X = 0
    else:
        r += A * X
        X = 0
    return r

print(solve(A, B, C, X, Y))

Submission status: Accepted

Solution code:
def solve(a, b, c, x, y):
    if 2 * c >= a + b:
        return a * x + b * y
    m = min(x, y)
    return 2 * c * m + min(a, 2 * c) * (x - m) + min(b, 2 * c) * (y - m)


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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

import sys, math, copy
# import fractions, itertools
# import numpy as np
# import scipy

HUGE = 2147483647
HUGEL = 9223372036854775807
ABC = "abcdefghijklmnopqrstuvwxyz"

def main():
    a, b, c, x, y = map(int, input().split())
    z = min(x, y)
    if c >= (a + b) * 0.5:
        return x * a + y * b
    else:
        if c < a * 0.5 and c < b * 0.5:
            return c * 2 * max(x, y)
        elif c < a * 0.5:
            return c * 2 * x + max(0, y - x) * b
        elif c < b * 0.5:
            return c * 2 * y + max(0, x - y) * a
        else:
            return c * 2 * z + (x - z) * a + (y - z) * b

print(main())

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:

a, b, ab, aa,bb = (int(i) for i in input().split())  

aok = 0
bok = 0
buya = 0
buyb = 0
buyab = 0
if a + b > ab*2:
  buyab = min(aa,bb)  * 2
  aok += buyab//2
  bok += buyab//2
buya = aa - aok
buyb = bb - bok

p1 = (buya*a + buyb*b + buyab*ab)

p2 = (ab*max(aa,bb)*2)
print(min(p1,p2))

Submission status: Accepted

Solution code:
l = map(int, raw_input().split())

if l[0] + l[1] > 2 * l[2]:
	if l[3] < l[4]:
		if (l[4] - l[3]) * l[1] < (l[4] - l[3]) * 2 * l[2]:
			print l[3] * 2 * l[2] + (l[4] - l[3]) * l[1]
		else:
			print l[4] * 2 * l[2]
	else:
		if (l[3] - l[4]) * l[0] < (l[3] - l[4]) * 2 * l[2]:
			print l[4] * 2 * l[2] + (l[3] - l[4])  * l[0]
		else:
			print l[3] * 2 * l[2]
else:
	print l[3] * l[0] + l[4] * l[1]

Submission status: Accepted

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

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

print(min(a*x+b*y, l, max(x,y)*2*c))

Submission status: Accepted

Solution code:
# ABピザ C

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

# c * 2 <= a + b

sum_num = 0

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

print(sum_num)

Submission status: Accepted

Solution code:
import sys
from collections import Counter

cin = sys.stdin
# cin = open("in.txt", "r")

def line2N():
    return map(int, cin.readline().split())

a,b,c,x,y = line2N()
ans1 = a*x + b*y
g = min(x,y)
ans3 = c*2*g + a*(x-g) + b*(y-g)
h = max(x,y)
ans4 = c*2*h


print(min(ans1, ans3, ans4))

Submission status: Accepted

Solution code:
import math

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 + a * (x - y)
#     else:
#         ans = 2 * c * x + a * (y - x)

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

Submission status: Accepted

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

    res = 10**10
    for q in range(2 * max(x, y) + 1):
        cost = q * c
        cost += max(x - int(q/2), 0) * a
        cost += max(y - int(q/2), 0) * b
        res = min(res, cost)
    print(res)

if __name__ == "__main__":
    solve()

Submission status: Accepted

Solution code:
import sys
from sys import stdin, stdout
import math
from copy import deepcopy
rem=10**9+7
sys.setrecursionlimit(10 ** 6)
take = lambda: map(int, stdin.readline().split())

a,b,c,x,y=take()
ans=10**12
d=max(x,y)*2
new=[]
while(d>=0):
    i=d/2
    j=d/2
    if i>=x:
        one=0
    else:
        one=(x-i)*a
    if j>=y:
        two=0
    else:
        two=(y-i)*b
    new.append(one+two+d*c)
    d-=1
print min(new)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

mn = min(x, y)

ans = 0

ans += min(a * mn + b * mn, 2 * mn * ab)

x -= mn
y -= mn

ans += min(x * a, 2 * x * ab)
ans += min(y * b, 2 * y * ab)

print(ans)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding : utf-8

import numpy as np

A = [int(i) for i in input().split()]

cost = 0

if A[0] + A[1] > A[2]*2:
	minl = min(A[3],A[4]) 
	cost += minl*2*A[2]
	A[3] -= minl
	A[4] -= minl
	if A[3] > 0:
		if A[0] > A[2]*2:
			cost += A[3]*2*A[2]
		else:
			cost += A[0]*A[3]
	else:
		if A[1] > A[2]*2:
			cost += A[4]*2*A[2]
		else:
			cost += A[1]*A[4]
else:
	cost += A[0]*A[3] + A[1]*A[4]

print(cost)

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

Submission status: Accepted

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

M = max(x, y)

def f(z):
    x2 = max(0, x - z)
    y2 = max(0, y - z)
    return 2*z*c + a*x2 + b*y2

print(min(f(i) for i in range(0, M+1)))

Submission status: Accepted

Solution code:

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


main()

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
def inpl(): return map(int, input().split())
A, B, C, X, Y = inpl()
print(min(A*X + B*Y, 2*X*C + max(0, Y-X)*B, 2*Y*C + max(0, X-Y)*A))