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 cmd():
    A, B, C, X, Y = map(int, input().split())
    buyAB = A*X + B*Y
    if X == Y:
        buyminC = C*2*min(X,Y)
    elif X > Y:
        buyminC = C*2*min(X,Y) + A*(X-Y)
    else:
        buyminC = C*2*min(X,Y) + B*(Y-X)
    buymaxC = C*2*max(X,Y)
    #print("buyAB:{}, buyminC:{}, buymaxC:{}".format(buyAB, buyminC, buymaxC))
    print(min(buyAB, buyminC, buymaxC))

if __name__ == "__main__":
    cmd()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

amax = x*a
bmax = y*b

ans = amax+bmax

for _ in range(max(x,y)):
    if x <= 0:
        ans = min(ans-b+2*c,ans)

    elif y <= 0:
        ans = min(ans-a+2*c,ans)

    else:
        ans = min(ans-a-b+2*c,ans)
        
    x-=1
    y-=1
 #   print(x,y,ans)

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

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

print(ans)

Submission status: Accepted

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#n=int(input())
a,b,c,x,y=map(int,input().split())
#al=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(m)]
ans=a*x+b*y
for z in range(0,max(x,y)+1):
    ans=min(ans,2*z*c+max(x-z,0)*a+max(y-z,0)*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:
    m = min(X,Y)
    M = max(X,Y)
    r = M-m
    cost = C*m*2
    
    if X > Y:
        cost += min(A*r,C*r*2)
    elif X < Y:
        cost += min(B*r,C*r*2)
    
    print(cost)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Tue Mar 31 11:16:07 2020

@author: liang
"""
###煩雑 => 列挙して最小値を出力
"""
A, B, C, X, Y = map(int,input().split())
if A + B > 2*C:
    if X > Y :
        if A < 2 * C:
            ans = Y * C * 2 + abs(X-Y) * A
        else:
            ans = X * C * 2  ##
    else:
        if B < 2 * C:
            ans = X * C * 2 + abs(X-Y) * B
        else:
            ans = Y * C * 2 ##
else:
    ans = X * A + Y * B 
print(ans)
"""
A, B, C, X, Y = map(int,input().split())
if A + B > 2*C:
    ans1 = max(X,Y) * C * 2  #条件分岐が減る
    if X > Y :
            ans2 = Y * C * 2 + abs(X-Y) * A           
    else:
            ans2 = X * C * 2 + abs(X-Y) * B  
    print(min(ans1,ans2)) #print()が分岐する
else:   
    ans1 = X * A + Y * B 
    print(ans1)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Tue Mar 31 11:16:07 2020

@author: liang
"""

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

Submission status: Accepted

Solution code:
def solve():
    a,b,c,x,y = map(int,input().split())
    ans = 10**12
    for i in range(max(x,y+1)):
        cost = c*2*i
        dx = max(0,x-i)
        dy = max(0,y-i)
        cost+=dx*a
        cost+=dy*b
        ans = min(ans,cost)
    print(ans)
if __name__ == "__main__":
    solve()

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

Submission status: Accepted

Solution code:
# https://atcoder.jp/contests/abc095/tasks/arc096_a

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

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

print(int(cost))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
input = lambda: sys.stdin.readline().rstrip() 

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

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

if __name__ == '__main__':
    resolve()

Submission status: Accepted

Solution code:
import sys
input = lambda: sys.stdin.readline().rstrip() 

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

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

if __name__ == '__main__':
    resolve()

Submission status: Accepted

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

"""
ABピザの購入数(0~2 * max(X, Y)で全探索)
"""
min_price = 10 ** 10
for i in range(2 * max(X, Y) + 1):
    c_price = C * i
    a_price = A * max(0, (X - i//2))
    b_price = B * max(0, (Y - i//2))
    min_price = min(min_price, a_price+b_price+c_price)
print(min_price)

Submission status: Accepted

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

Submission status: Accepted

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

ret=10**10

for i in range(max(2*X,2*Y)+1):
    cx=X-i//2
    cy=Y-i//2

    price=max(0,cx)*A+max(0,cy)*B+i*C
    ret=min(ret,price)

print(ret)

Submission status: Accepted

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

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

print(min(ans1,ans2,ans3))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
import copy
from copy import deepcopy
import sys
import fractions
# import numpy as np
from functools import reduce
# import statistics
import decimal
import heapq
import collections
import itertools
from operator import mul

sys.setrecursionlimit(100001)


# input = sys.stdin.readline
# sys.setrecursionlimit(10**6)

# ===FUNCTION===

def getInputInt():
    inputNum = int(input())
    return inputNum


def getInputListInt():
    outputData = []
    inputData = input().split()
    outputData = [int(n) for n in inputData]

    return outputData


def getSomeInputInt(n):
    outputDataList = []
    for i in range(n):
        inputData = int(input())
        outputDataList.append(inputData)

    return outputDataList


def getSomeInputListInt(n):
    inputDataList = []
    outputDataList = []
    for i in range(n):
        inputData = input().split()
        inputDataList = [int(n) for n in inputData]
        outputDataList.append(inputDataList)

    return outputDataList


# ===CODE===

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

itr = max(x, y)*2+1

ans = sys.maxsize
for i in range(itr):
    tmpa = max(0, a*(x-i//2))
    tmpb = max(0, b*(y-i//2))
    tmpc = c*i
    tmp_cost = tmpa+tmpb+tmpc
    ans = min(ans, tmp_cost)

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    A,B,C,x,y = map(int, readline().split())

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


if __name__ == "__main__":
    main()

Submission status: Accepted

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

#N = int(input())
#H, W = map(int, input().split())
#S = [input() for _ in range(H)]
#print(A[0][0])

easy = A * X + B * Y
maxnum = max(X, Y) * 2
for i in range(maxnum, 1, -2):
    tmp = 0
    if (i == maxnum): tmp = C * i
    elif (X - (i / 2) > 0 and Y - (i / 2) > 0): tmp = A * (X - (i / 2)) + B * (Y - (i / 2)) + C * i
    elif (X - (i / 2) > 0): tmp = A * (X - (i / 2)) + C * i
    elif (Y - (i / 2) > 0): tmp = B * (Y - (i / 2)) + C * i
    if (tmp < easy): easy = tmp
print(int(easy))

Submission status: Accepted

Solution code:
A,B,C,X,Y = map(int,input().split())
C *= 2
ax = 0
bx = 0
num = 0
while ax < X or bx < Y:
  if ax < X and bx < Y:
    if A+B < C:
      num += A+B
    else:
      num += C
    ax += 1
    bx += 1
  elif ax < X:
    if A < C:
      num += A
    else:
      num += C
    ax += 1
  else:
    if B < C:
      num += B
    else:
      num += C
    bx += 1
print(num)

Submission status: Accepted

Solution code:
# https://atcoder.jp/contests/abc095/tasks/arc096_a


# A1枚→A円
# B1枚→B円
# A,B両方一枚→AB円


# もし2AB<=A+Bならmin(X,Y)になるまで買ったほうが安い
# Aだけ必要→A<AB→Aを買う、違うならABを買う
# Bだけ必要→上に同じ

# もし2AB<=A+Bでなかった場合
# A,B<ABの場合→A,Bを個別に買う
# A<2AB の場合→Aは個別で
# この議論は上に統合される

a, b, c, x, y = map(int, input().split())
# 両方買うほうがお得のときは先に買っておく
ans = 0
if 2 * c <= a + b:
    n = min(x, y)
    ans += 2 * n * c
    x -= n
    y -= n

# print(x, y, ans)

# Aだけ買う
if a <= 2 * c:
    ans += x * a
else:
    ans += x * 2 * c

if b <= 2 * c:
    ans += y * b
else:
    ans += y * 2 * c
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

ans = max(x,y)*2*c
s = max(x,y)

while s:
    tmp = 0
    tmp -= c*2
    s -= 1
    if x > s:
        tmp += a
    if y > s:
        tmp += b
    if tmp > 0:
        print(ans)
        exit()
    else:
        ans += tmp
        
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

cmx = max(x, y)*2

ans = 10**9+7
for cn in range(cmx+1):
    an = max(0, x - cn//2)
    bn = max(0, y - cn//2)
    total = an*a + bn*b + cn*c
    ans = min(ans, total)

print(ans)

Submission status: Accepted

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

res = float("inf")
if a + b <= ab:
    res = x * a + y * b
else:
    if x == y:
        res = x * ab
    elif x > y:
        for i in range(y, x + 1):
            cost = i * ab + (x - i) * a
            res = min(res, cost)
    else:
        for i in range(x, y + 1):
            cost = i * ab + (y - i) * b
            res = min(res, cost)
print(res)

Submission status: Accepted

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

ans = 0
if (A + B) / 2 >= C:
    #AB = C
    ans += min(X, Y) * C * 2
    X, Y =X - min(X, Y), Y - min(X, Y)

if A >= 2 * C:
    A = 2 * C
if B >= 2 * C:
    B = 2 * C

while X != 0:
    ans += A
    X -= 1
while Y != 0:
    ans += B
    Y -= 1

print(ans)

Submission status: Accepted

Solution code:
import sys
stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)

i_i = lambda: int(i_s())
i_l = lambda: list(map(int, stdin.readline().split()))
i_s = lambda: stdin.readline().rstrip()

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

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

Submission status: Accepted

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

    price_no_ab = A * X + B * Y

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

    if X < Y:
        price_ab = C * 2 * Y
    else:
        price_ab = C * 2 * X

    # print([price_use_ab, price_no_ab, price_ab])
    return min([price_use_ab, price_no_ab, price_ab])


if __name__ == "__main__":
    result = solve()
    print(result)

Submission status: Accepted

Solution code:
a,b,c,x,y = map(int,input().split())
ans = a*x+b*y
for i in range(2*max(x,y)+1):#ABピザを買う枚数で全探索
  ans = min(ans,i*c+max(0,(x-(i//2)))*a+max(0,(y-(i//2)))*b)
print(ans)

Submission status: Accepted

Solution code:
#n=int(input())
a,b,c,x,y=map(int,input().split())
#l=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]

ans=a*x+b*y

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

Submission status: Accepted

Solution code:
def main():
    import math

    a, b, c, x, y = map(int, input().split())
    d = [a, b]
    i, j = min(x, y), max(x, y)
    n = math.ceil(i / 2)
    f = j == x
    if 2 * c > (a + b):
        ans = a * x + b * y
    else:
        ans = 2 * c * i + (j - i) * min(c * 2, d[not f])

    print(ans)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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


def solve(A: int, B: int, C: int, X: int, Y: int):
    c = 0
    if (A + B < 2 * C):
        c += min(X, Y) * (A + B)
    else:
        c += min(X, Y) * 2 * C
    if X > Y:
        c += (X - Y) * min(A, 2 * C)
    else:
        c += (Y - X) * min(B, 2 * C)
    print(c)
    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
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())

val=a*x+b*y
val2=2*c*x+b*(y-x) if y>x else 2*c*y+a*(x-y)
val3=2*c*max(x,y)
print(min(val,val2,val3))

Submission status: Accepted

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

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

    print(ans)

Submission status: Accepted

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

    total_min = a * x + b * y

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

if __name__ == "__main__":
    main()

Submission status: Accepted

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

    total_min = a * x + b * y

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

if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

Submission status: Accepted

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

    print(ans)

if __name__ == '__main__':
    resolve()

Submission status: Accepted

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

Submission status: Accepted

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

xn, yn = 0, 0
price = 0

if A >= 2*C and X > xn:
    ammount = X - xn
    price += C * X * 2
    xn += X
    yn += X

if B >= 2*C and Y > yn:
    ammount = Y - yn
    price += C * ammount * 2
    xn += ammount
    yn += ammount

if (A+B) >= 2*C and (X - xn) >= 1 and (Y - yn) >= 1:
    ammount = min(X, Y)
    price += C * ammount * 2
    xn += ammount
    yn += ammount


if X - xn >= 1:
    price += A * (X - xn)

if Y - yn >= 1:
    price += B * (Y - yn)

print(price)


# min_price = 1 << 32 
# for i in range(max(X, Y)+1):
#     xn, yn = i, i
#     price = (2*C) * i
#     price += (max(0, X - xn)) * A
#     price += (max(0, Y - yn)) * B
#     min_price = min(min_price, price)
# 
# print(min_price)

Submission status: Accepted

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

# xn, yn = 0, 0
# price = 0
# 
# if (A+B) >= 2*C and A >= 1 and B >= 1:
#     ammount = min(X, Y)
#     price += C * ammount * 2
#     xn += ammount
#     yn += ammount
# 
# if A >= 2*C and X > xn:
#     ammount = X - xn
#     price += C * X * 2
#     xn += X
#     yn += X
# 
# if B >= 2*C and Y > yn:
#     ammount = Y - yn
#     price += C * ammount * 2
#     xn += ammount
#     yn += ammount
# 
# price += A * (X - xn)
# price += B * (Y - yn)
# 
# print(price)
# 

min_price = 1 << 32 
for i in range(max(X, Y)+1):
    xn, yn = i, i
    price = (2*C) * i
    price += (max(0, X - xn)) * A
    price += (max(0, Y - yn)) * B
    min_price = min(min_price, price)

print(min_price)

Submission status: Accepted

Solution code:
def inpl():
    return list(map(int, input().split()))


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

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

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

print(ans)

Submission status: Accepted

Solution code:
def HalfPizza(a , b , c , x , y):

    ans = 0

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

    return ans

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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


def II(): return int(input())
def MI(): return map(int,input().split())
def LI(): return list(map(int,input().split()))

# mod=10**9+7
# rstrip().decode('utf-8')

def main():
	a,b,c,x,y=MI()
	ans=10**10
	ans=min(a*x+b*y,c*max(x,y)*2,c*min(x,y)*2+(a*(x-min(x,y)) if x>y else b*(y-min(x,y))))
	print(ans)











if __name__ == "__main__":
	main()

Submission status: Accepted

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

    print(ans)

if __name__ == '__main__':
    resolve()

Submission status: Accepted

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


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

    print(
        min(X * A + Y * B,
            2 * X * C + B * max(0, Y - X),
            2 * Y * C + A * max(0, 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:
  Z = 2 * min(X, Y)
  X_rem = X - Z // 2
  Y_rem = Y - Z // 2
  
  if (X_rem != 0) and (A > 2*C):
    print(C*(2*X))
  elif (Y_rem != 0) and (B > 2*C):
    print(C*(2*Y))
  else:
    print(A*X_rem + B*Y_rem + C*Z)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

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

xy_min = 0
xy_max = 0
if X > Y:
    xy_min = Y
    xy_max = X
else:
    xy_min = X
    xy_max = Y

ans2 = xy_max*AB


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

    ans += A*X
    ans += B*Y
else:
    ans += A*X
    ans += B*Y

print(min(ans, ans2))

Submission status: Accepted

Solution code:
from __future__ import print_function

import sys

import re
import array
import copy
import functools
import operator

import math
import string
import fractions
from fractions import Fraction
from fractions import gcd
# fractions.gcd() を用いること
# math.log2()はatcoderでは対応していない．留意せよ．

import collections
import itertools
import bisect

import random
import time

import heapq
from heapq import heappush
from heapq import heappop
from heapq import heappushpop
from heapq import heapify
from heapq import heapreplace
from queue import PriorityQueue as pq
from queue import Queue

from itertools import accumulate

from collections import deque
from collections import Counter

from operator import mul
from functools import reduce

input = sys.stdin.readline


def eprint(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)
    return


def lcm(n, m):
    return int(n * m / gcd(n, m))


def coprimize(p, q):
    common = fractions.gcd(p, q)
    return (p // common, q // common)


def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


def find_gcd(list_l):
    x = reduce(gcd, list_l)
    return x


def main():
    a, b, c, x, y = map(int, input().strip().split())
    t1=a*x + b*y
    t2=c * 2 * min(x, y) + (a if x > y else b)*(max(x, y) - min(x, y))
    t3=c * 2 * max(x, y)
    print(min(t1,t2,t3))

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# import bisect
# import heapq
# from copy import deepcopy
# from collections import deque
# from collections import Counter
# from itertools import accumulate
# from itertools import permutations
# import numpy as np
# import math
# mod = 10**9 + 7

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

mn = 10**10
for i in range(max(x,y) + 1):
    if x<=i<=y:
        total = 2*c*i + b*(y-i)
    elif y<=i<=x:
        total = 2*c*i + a*(x-i)

    else:
        total = 2*c*i + a*(x-i) + b*(y-i)

    mn = min(mn, total)

print(mn)

Submission status: Accepted

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

normal_price = a * x + b * y
min_price = float('inf')
minn = min(x, y)
maxx = max(x, y)

for mi in range(2, maxx * 2 + 1, 2):
    mix_price = c * mi
    xz = x - mi // 2
    yz = y - mi // 2
    if xz < 0: xz = 0
    if yz < 0: yz = 0
    x_price = xz * a
    y_price = yz * b
    total_price = mix_price + x_price + y_price
    min_price = min(min_price, total_price)

min_price = min(min_price, normal_price)
print(min_price)

Submission status: Accepted

Solution code:
def resolve():
    A, B, C, X, Y = map(int, input().split())
    C *= 2
    AB = A+B
    ans = 0
    while X > 0 or Y > 0:
        min_cnt = min(X, Y)
        if X and Y:
            if min_cnt*C <= (A*min_cnt) + (B*min_cnt):
                ans += min_cnt*C
                X -= min_cnt
                Y -= min_cnt
            else:
                ans += (A*min_cnt) + (B*min_cnt)
                X -= min_cnt
                Y -= min_cnt
        else:
            if max(X, Y)*C <= (A*X) + (B*Y):
                ans += max(X, Y)*C
                X -= max(X, 0)
                Y -= max(Y, 0)
            else:
                ans += (A*X) + (B*Y)
                X -= max(X, 0)
                Y -= max(Y, 0)
    return print(ans)

if __name__ == "__main__":
    resolve()

Submission status: Accepted

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

Submission status: Accepted

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


if a + b <= c*2:
  buy = a*x + b*y
elif a + b > c*2:
  num = [x,y]
  num.sort()
  buy = c*2*num[0]
  num_rest = num[1] - num[0]
  if num[1] == x:
    if a <= c*2:
      buy += a*num_rest
    else:
      buy += c*2*num_rest
  elif num[1] == y:
    if b <= c*2:
      buy += b*num_rest
    else:
      buy += c*2*num_rest
      
print(buy)

Submission status: Accepted

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

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

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

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

Submission status: Accepted

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

Submission status: Accepted

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

s = set()
s.add(a*x + b*y)
if x < y:
    s.add(2*x*c + b*(y-x))
    s.add(2*(x+1)*c + b*(y-x-1))
    s.add(2*y*c)
    print(min(s))
else:
    s.add(2*y*c + a*(x-y))
    s.add(2*(y+1)*c + a*(x-y-1))
    s.add(2*x*c)
    print(min(s))

Submission status: Accepted

Solution code:
a,b,c,x,y=map(int, input().split())
z = 0#xy
l= []
l.append(a * x+b * y)
while x > 0 or y > 0:
    x -= 1
    y -= 1
    z += 2
    x1 = x
    if x1 < 0: x1 = 0
    y1 = y
    if y1 < 0: y1 = 0
    l.append(a * x1 + y1 * b + z * c)
print(min(l))

Submission status: Accepted

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

for i in range(big+1):
    x = X - i if X - i >= 0 else 0
    y = Y - i if Y - i >= 0 else 0 
    goukei = (A*x)+(B*y)+(C*i*2) 
    ans.append(goukei)
print(min(ans))