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

  print(ans)
  return

if __name__ == "__main__":
  resolve()

Submission status: Accepted

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

ans = 10 ** 9
for c in range(max(X, Y) + 1):
    tmp = 2 * C * c
    tmp += A * max(0, X - c)
    tmp += B * max(0, Y - c)
    ans = min(ans, tmp)

print (ans)

Submission status: Accepted

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

pay = 0
same = min(X, Y)
pay += same * min(A + B, C * 2)

X -= same
Y -= same

pay += X * min(A, C * 2)
pay += Y * min(B, C * 2)

print(pay)

Submission status: Accepted

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

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

print(min(A,B,C))

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    a, b, c, x, y = map(int, input().split())
    AB_sum = min(a + b, c * 2)  # AB1枚ずつの最小値
    ans = 0
    ans += min(x, y) * AB_sum
    if x < y:
        if b < c * 2:
            ans += b * (y - x)
        else:
            ans += (c * 2) * (y - x)
    else:
        if a < c * 2:
            ans += a * (x - y)
        else:
            ans += (c * 2) * (x - y)
    print(ans)

Submission status: Accepted

Solution code:
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    A,B,C,x,y = LI()
    ans = float("inf")
    for c in range(0,2*(x+y+1),2):
        resa = max(0,x-(c >> 1))
        resb = max(0,y-(c >> 1))
        s = resa*A+resb*B+c*C
        if s < ans:
            ans = s
    print(ans)
    return

#Solve
if __name__ == "__main__":
    solve()

Submission status: Accepted

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

cost = [
    a * x + b * y,
    2 * c * max(x, y),
    2 * c * min(x, y) + (a if x > y else b) * abs(x - y)
]

print(min(cost))

Submission status: Accepted

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

aaa=[]

aaa.append(2*c*max([x,y]))
aaa.append(a*x+b*y)

if x > y:
    aaa.append(2*c*y+a*(x-y))
elif x < y:
    aaa.append(2*c*x+b*(y-x))

print(min(aaa))

Submission status: Accepted

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

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

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

print(cost)

Submission status: Accepted

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

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 5 + 10)


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


def resolve():
    a, b, c, x, y = map(int, input().split())
    ans = 10 ** 10
    yen = 0
    if a + b > c * 2:
        yen += (c * 2 * min(x, y))
        x, y = x - min(x, y), y - min(x, y)

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

    else:
        yen += a * x + b * y
    print(yen)


resolve()

Submission status: Accepted

Solution code:
def calcPizza(k, mai):
    return k*mai

a,b,c,x,y = [int(i) for i in input().split(' ')]
mins = min(x,y)

asum = calcPizza(a, x)
bsum = calcPizza(b, y)
absum = calcPizza(c,mins*2)
if x > mins:
    atmp= calcPizza(a,x-mins)
    abtmp= calcPizza(c,(x-mins)*2)
    absum += min(atmp,abtmp)
elif y > mins:
    btmp = calcPizza(b,y-mins)
    abtmp = calcPizza(c,(y-mins)*2)
    absum += min(btmp,abtmp)
print(min(asum+bsum, absum))

Submission status: Accepted

Solution code:
import sys

def solve():
    input = sys.stdin.readline
    A, B, C, X, Y = map(int, input().split())
    C *= 2
    minCost = A * X + B * Y
    minCost = min(minCost, C * max(X, Y))
    if X >= Y: minCost = min(minCost, A * (X - Y) + C * Y)
    else: minCost = min(minCost, B * (Y - X) + C * X)
    print(minCost)


    return 0

if __name__ == "__main__":
    solve()

Submission status: Accepted

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

        ans+=b*(y-x)

print(ans)

Submission status: Accepted

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

  print(ans)
  return

if __name__ == "__main__":
  resolve()

Submission status: Accepted

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

ans = 1000000007
for i in range(max(X, Y) + 1):
    i_C = 2 * i
    i_A = max(0, X - i)
    i_B = max(0, Y - i)
    #
    ans = min(ans, A * i_A + B * i_B + C * i_C)

print(ans)

Submission status: Accepted

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

ans = 10 ** 18
for i in range(max(X, Y) + 1): #ABピザを2 * i枚買う
    tmp = 2 * i * C
    x = max(0, X - i)
    y = max(0, Y - i)
    tmp += x * A + y * B
    ans = min(ans, tmp)

print (ans)

Submission status: Accepted

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

    ans = 1000000007
    for i in range(100001):
        cost = c * i * 2 + a * max(0, x - i) + b * max(0, y - i)
        if cost < ans:
            ans = cost

    print(ans)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

ans = float('inf')
for k in range(0, 2 * max(X, Y) + 1, 2):
    i = max(X - k // 2, 0)
    j = max(Y - k // 2, 0)
    ans = min(ans, A * i + B * j + C * k)

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
a,b,c,x,y = map(int,input().split())
c *= 2
answer = 0
if x < y:
    answer += c*x + b*(y - x)
    if a + b < c:
        print(a*x+b*y)
    else:
        if b > c:
            print(c*y)
        else:
            print(answer)
elif x > y:
    answer += a*(x-y)+c*y
    if a + b < c:
        print(a*x+b*y)
    else:
        if a > c:
            print(c*x)
        else:
            print(answer)
else:
    answer += c*x
    if a + b < c:
        print(a*x+b*y)
    else:
        print(answer)

Submission status: Accepted

Solution code:
# -*- coding:utf-8 -*-
# https://atcoder.jp/contests/abc095/tasks/arc096_a

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

    ans = 0
    # 用意するピザの少ない方をまず買う
    if A+B <= C*2:
        # 1枚ずつ買ったほうが安い場合
        if X <= Y:
            ans += A*X + B*X
        else:
            ans += A*Y + B*Y
    else:
        # Cを2枚買った方が安い場合
        ans += min(X, Y)*C*2

    # 残りのピザを買う
    if X >= Y:
        if A <= C*2:
            ans += (X-Y)*A
        else:
            ans += (X-Y)*C*2
    else:
        if B <= C*2:
            ans += (Y-X)*B
        else:
            ans += (Y-X)*C*2

    print(ans)


if __name__ == "__main__":
    solve()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

if X == Y :
  print( X* min( cost1, cost2))
elif X > Y:
  a = Y * min( cost1, cost2) + ( X - Y) * A
  b = X * min( cost1, cost2)
  print( min( a, b))
else :
  a = X * min( cost1, cost2) + ( Y - X) * B
  b = Y * min( cost1, cost2)
  print( min(a,b))

Submission status: Accepted

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

for i in range(max(2*x+1,2*y+1)):
    a_money=max(a*(x-i),0)
    b_money=max(b*(y-i),0)
    money=min(money,a_money+b_money+i*c*2)

print(money)

Submission status: Accepted

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

sum = a * x + b * y
s = [sum]
for i in range(max(x,y)):
    if (x>0) and (y>0):
        x -= 1
        y -= 1
        sum = sum + (2 * c - a - b)

    elif (x>0):
        x -= 1
        sum = sum + (2 * c - a)

    elif (y>0):
        y -= 1
        sum = sum + (2* c - b)

    s.append(sum)
    #print(sum)
print(min(s))

Submission status: Accepted

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

non_AB = A*X + B*Y
if X>Y:
#BをABから作る
    non_B = C*2*Y + A*(X-Y)
#AをABから作る
    non_A = C*2*X
else:
    non_A = C*2*X + B*(Y-X)
    non_B = C*2*Y


# print(min(non_AB, use_AB))
print(min(non_AB, non_A, non_B))

Submission status: Accepted

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

Submission status: Accepted

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

print(a*cnta+b*cntb+c*cntab)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def LI(): return list(map(int,input().split()))
A,B,C,X,Y = LI()
ans = float('INF')
for i in range(max(X,Y)+1):
    price = A*max(X-i,0)+B*max(Y-i,0)+C*2*i
    ans = min(ans,price)
print(ans)

Submission status: Accepted

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

#直接買ったほうが安いとき

if a+b<c*2:
    print(a*x+b*y)
    
#AピザよりもABピザ２枚のほうが安い
elif a+b>=c*2:
    if x-y>0 and a<=2*c:
        print(2*c*y+(x-y)*a)
    elif y-x>0 and b<=2*c:
        print(2*c*x+(y-x)*b)
    elif x-y>0:
        print(x*2*c)
    else:
        print(y*2*c)

Submission status: Accepted

Solution code:
def LI(): return list(map(int,input().split()))
A,B,C,X,Y = LI()
ans = float('INF')
for i in range(max(X,Y)+1):
    price = A*max(X-i,0)+B*max(Y-i,0)+C*2*i
    ans = min(ans,price)
print(ans)

Submission status: Accepted

Solution code:
import math
import itertools
import numpy as np

def solve():
    a, b, c, x, y = map(int, input().split())
    case1 = a * x + b * y
    case2 = x * 2 * c + max(0, (y - x) * b)
    case3 = max(0, (x - y) * a) +  y * 2 * c
    case4 = max(x, y) * 2 * c
    print(min(case1, case2,case3,case4))
    return 0

if __name__ == "__main__":
    solve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
pa, pb, pab, x, y = map(int, input().split())
li = []
if x-y>= 0:
    li.append(pa*x+pb*y)
    li.append(pa*(x-y)+pab*2*y)
    li.append(pab*2*x)
if y-x>= 0:
    li.append(pa*x+pb*y)
    li.append(pb*(y-x)+pab*2*x)
    li.append(pab*2*y)
li.sort()
print(li[0])

Submission status: Accepted

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

#mxy = max(x, y)
#sxy = min(x, y)
#sum = 0
# if a+b-2*c > 0:
#    sum += c*min(x, y)*2
#    if x > y and a < 2*c:
#        sum += (max(x, y)-min(x, y))*a
#    elif x > y:
#        sum += (max(x, y)-min(x, y))*2*c
#    elif x <= y and a < 2*c:
#        sum += (max(x, y)-min(x, y))*b
#    elif x <= y:
#        sum += (max(x, y)-min(x, y))*2*c
# else:
#    sum = a*x+b*y
# print(sum)
#
amin = a*x+b*y
sum = 0
for i in range(0, max(x, y)*2+1, 2):
    sum = (x-i//2 if x-i//2 > 0 else 0)*a+(y-i//2 if y-i//2 > 0 else 0)*b+c*i
    if sum < amin:
        amin = sum
print(amin)

Submission status: Accepted

Solution code:
# 2020/04/23
# AtCoder Beginner Contest 095 - C

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

# Calc
case1 = a * x + b * y
case2 = x * 2 * c + max(0, (y - x) * b)
case3 = max(0, (x - y) * a) +  y * 2 * c
case4 = max(x, y) * 2 * c

ans = min(case1, case2, case3, case4)

# Output
print(ans)

Submission status: Accepted

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

A_B = A * X + B * Y
all_C = max(X, Y) * 2 * C
part_C = min(X, Y) * 2 * C + (X < Y) * (Y - X) * B + (Y < X) * (X - Y) * A

print(min(A_B, all_C, part_C))

Submission status: Accepted

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

cost = A*X + B*Y
a = X
b = Y
c  = 0
N = max(X,Y)

for i in range(N):
  c += 2
  if a > 0:
    a -= 1
  if b > 0:
    b -= 1
  cost = min(cost,A*a + B*b + c*C)
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:
    ans = c * min(x, y) * 2
    if x > y:
        if a < c * 2:
            ans += a * (x - y)
        else:
            ans += c * 2 * (x - y)
    else:
        if b < c * 2:
            ans += b * (y - x)
        else:
            ans += c * 2 * (y - x)
    print(ans)

Submission status: Accepted

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

A = a*x + b*y
B = 2*c*max(x,y)

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

Submission status: Accepted

Solution code:
A,B,C,X,Y=map(int,input().split())
direct=A*X+B*Y
W=min(X,Y)
Z=max(X,Y)
if Z==X:
    E=A
    D=B
else:
    E=B
    D=A
over=Z*C*2
under=W*C*2+(Z-W)*E

print(min(direct,over,under))

Submission status: Accepted

Solution code:
A, B, C, X, Y = map(int, input().split())
a = X
b = Y
c = 0
ans = a*A + b*B + c*C
while(a > 0 or b > 0):
  a = max(a-1, 0)
  b = max(b-1, 0)
  c += 2
  tmp = a*A + b*B + c*C
  if(tmp < ans):
    ans = tmp
  
print(ans)

Submission status: Accepted

Solution code:
# coding: utf-8

# https://atcoder.jp/contests/abc095/tasks/arc096_a
# 16:32-16:44


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

    if y > x:
        a, b, x, y = b, a, y, x
    # aの方が枚数（x)多い

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

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

    return ans


print(main())

Submission status: Accepted

Solution code:
A,B,C,X,Y = map(int, input().split())
mn = min((A+B)/2, C)
ans1 = 0
ans1 += min(X,Y)*2*mn
if X > Y:
    ans1 += A*(X-Y)
elif Y> X:
    ans1 += B*(Y-X)
ans2 = 0
ans2 += C*max(X, Y)*2
print(int(min(ans1,ans2)))

Submission status: Accepted

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

Submission status: Accepted

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

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

tmp = min(x, y)
ans2 = c*tmp*2 + a*max(x-tmp, 0) + b*max(y-tmp, 0)

ans3 = a*x + b*y

print(min(ans1, ans2, ans3))

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Y-=X
tmp=B*Y
for y in range(Y):
  tmp2=B*y+C*(Y-y)*2
  if tmp > tmp2:
    tmp=tmp2
print(ans+tmp)

Submission status: Accepted

Solution code:
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

def main():
    a, b, c, x, y = nm()

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

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

a = A*X+B*Y
b = max(X, Y) * 2 * C

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

print(min(a, b, c))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
sum = 0
A,B,C,X,Y = map(int,input().split())
AB = C*2
ans = float("inf")

for i in range(10**5+1):
    sum = AB*i + A*max(0,X-i) + B*max(0,Y-i)
    if sum < ans:
        ans = sum

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

print(sum)

Submission status: Accepted

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

t1 = a*x + b*y
t2 = max(x, y)*2 * c

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
I = [int(i) for i in input().split()]
A, B, AB, X, Y = I

ans = 1e+15
for i in range(max(X,Y)+1):
  price = A*max(X-i, 0) + B*max(Y-i, 0) + AB*2*i
  ans = min(ans, price)
print(ans)

Submission status: Accepted

Solution code:
# solution

import io
import sys

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 7)

A,B,C,X,Y = map(int,readline().split())
L = []
L.append(A*X+B*Y)
for i in range(1, min(X,Y)+1):
    sum = A*(X-i)+B*(Y-i)+C*2*i
    L.append(sum)
ans = min(L)
if max(X,Y)*2*C<ans:
    ans = max(X,Y)*2*C
print(ans)

Submission status: Accepted

Solution code:
# from math import factorial,sqrt,ceil,gcd
# from itertools import permutations as permus
# from collections import deque,Counter
# import re
# from functools import lru_cache # 簡単メモ化 @lru_cache(maxsize=1000)
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# import networkx as nx
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix
# from scipy.special import comb

# slist = "abcdefghijklmnopqrstuvwxyz"
A,B,C,X,Y = map(int,input().split())

costA = min(A,C*2)
costB = min(B,C*2)
costAB = min(A+B,C*2,A+costB,costA+B)

numAB = min(X,Y)
numA = max(X-Y,0)
numB = max(Y-X,0)

ans = numA*costA + numB*costB + numAB*costAB

print(ans)
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する
# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))

Submission status: Accepted

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


def solve(A: int, B: int, C: int, X: int, Y: int):
    print(min(
        A * X + B * Y + min(X, Y) * min(0, C * 2 - A - B),
        max(X, Y) * (C * 2),
    ))


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    X = int(next(tokens))  # type: int
    Y = int(next(tokens))  # type: int
    solve(A, B, C, X, Y)


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

Submission status: Accepted

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

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

Submission status: Accepted

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

def main():
    A, B, C, X, Y = map(int, readline().rstrip().split())
    if A + B <= 2 * C:
        print(X * A + Y * B)
        return
    
    m = min(X, Y)
    ans = m * 2 * C
    X -= m
    Y -= m
    ans += min(X * A + Y * B, max(X, Y) * 2 * C)
    
    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(2 * C * (min(X, Y)) + min(A, 2 * C) * (X - min(X, Y)) + min(B, 2 * C) * (Y - min(X, Y)))
else:
    print(A * X + B * Y)

Submission status: Accepted

Solution code:

a,b,c,x,y=map(int,input().split())
money1=a*x+b*y
money2=min(min(x,y)*2*c+a*(x-min(x,y))+b*(y-min(x,y)),max(x,y)*2*c)
print(min(money1,money2))

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
a, b, c, x, y = map(int, input().split())
cos = 0
if x < y:
    flag = True
    f = y-x
else:
    flag = False
    f = x-y
if 2*c < a+b:
    cos += min(x, y)*2*c
else:
    cos += min(x, y)*(a+b)
if (2*c < a and flag == False) or (2*c < b and flag):
    cos += f*2*c
else:
    if flag:
        cos += f*b
    else:
        cos += f*a
print(cos)

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

Submission status: Accepted

Solution code:
a, b, c, x, y = map(int, input().split())
z = max(x, y)
ans = float('inf')
#ABピザの枚数をiとする
for i in range(0, 2 * z + 1, 2):
    #合計費用
    total = a * max(0, (x - (i // 2))) + b *max(0, (y - (i // 2))) + c * i
    ans = min(ans, total)
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
INF = int(1e5)+5

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