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 smaller(x, y):
	if x < y: return x
	return y

A, B, AB, X, Y = map(int, input().split())
sum = 0
if A + B <= 2 * AB:
	sum += A * X + B * Y
else:
	pizzaset = 2 * smaller(X, Y)
	sum += pizzaset * AB
	X -= pizzaset // 2
	Y -= pizzaset // 2
	if X == 0:
		if B <= 2 * AB:
			sum += B * Y
		else:
			sum += 2 * Y * AB
	else:
		if A <= 2 * AB:
			sum += A * X
		else:
			sum += 2 * X * AB
print(sum)

Submission status: Accepted

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

cost_a = a * x
w_x = x

cost_b = b * y
w_y = y

if c * 2 < a + b:
    w_c = min(x, y) * 2
    w_x = x - min(x, y)
    w_y = y - min(x, y)

    if w_x > 0:
        if a > c * 2:
            w_c += w_x * 2
            w_x = 0

    if w_y > 0:
        if b > c * 2:
            w_c += w_y * 2
            w_y = 0

    print(w_x * a + w_y * b + w_c * c)
else:
    print(cost_a + cost_b)

Submission status: Accepted

Solution code:
import bisect
import heapq
import itertools
import math
import os
import re
import string
import sys
from collections import Counter, deque, defaultdict
from copy import deepcopy
from decimal import Decimal
from fractions import gcd
from functools import lru_cache, reduce
from operator import itemgetter

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

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

A, B, C, X, Y = list(map(int, sys.stdin.readline().split()))

# そのまま買う
a1 = A * X + B * Y
# AB だけ使う
a2 = C * max(X, Y) * 2
# 少ない方に AB を使う
a3 = C * min(X, Y) * 2
if X > Y:
    a3 += A * (X - Y)
else:
    a3 += B * (Y - X)

print(min(a1, a2, a3))

Submission status: Accepted

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

Submission status: Accepted

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

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

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

Submission status: Accepted

Solution code:
from sys import stdin
A,B,C,X,Y = [int(x) for x in stdin.readline().rstrip().split()]
ans = 10**9
for i in range(0,2*(max(X,Y)+1)):
    total = A*max((X-(i//2)),0) + B*max((Y-(i//2),0)) + i*C
    #print(total,i)
    if total > 0 and total < ans:
        ans = total
print(ans)

Submission status: Accepted

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

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

ans_2 = max(Y, X) * C * 2

ans_3 = X * A + Y * B

print(min(ans_1, ans_2, ans_3))

Submission status: Accepted

Solution code:
A,B,C,X,Y = (int(_) for _ in input().split())
all_ab =max(X,Y)*C*2
no_ab = A*X + B*Y
if X>=Y:
    ab = Y*2*C + (X-Y)*A
else:
    ab = X*2*C + (Y-X)*B
print(min(all_ab,no_ab,ab))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left
from bisect import bisect_right
from collections import defaultdict
from heapq import heappop, heappush
import numpy as np
import statistics
from statistics import mean, median,variance,stdev
import math

def main():
	A,B,C,X,Y = map(int, input().split(" "))
	
	if C >= A and C >= B:
		
		print(A*X + B*Y)
		sys.exit()
	
	base = A*X + B*Y
	
	if X == Y:
		tmp = C * 2 * Y
		
		print(min(base, tmp))
		sys.exit()
	

	part1 = A*X
	part21 = C*2*Y
	part22 = B*Y
	tmp = min(part21,part22)
	tmp = part1 + tmp
	ans = min(base, tmp)
	#print(ans)
			
	part1 = C*2*X
	Y_tmp = Y-X
	if Y_tmp > 0:	
		part21 = C*2*Y_tmp
		part22 = B*Y_tmp
		tmp = min(part21,part22)
		tmp = part1 + tmp
	else:
		tmp = part1
	ans = min(ans, tmp)
	#print(ans)
	
	part1 = B*Y
	part21 = C*2*X
	part22 = A*X
	tmp = min(part21,part22)
	tmp = part1 + tmp
	ans = min(ans, tmp)
	#print(ans)
		
	part1 = C*2*Y
	X -= Y
	if X > 0:
		part21 = C*2*X
		part22 = A*X
		tmp = min(part21,part22)
		tmp = part1 + tmp
	else:
		tmp = part1
	ans = min(ans, tmp)
			
	print(ans)
	
if __name__ == "__main__":
	main()

Submission status: Accepted

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

Submission status: Accepted

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

sum_ab = a + b
double_c = c * 2
cheaper = sum_ab if sum_ab <= double_c else double_c
lesser = x if x < y else y
moreer = x if x >= y else y
base_cost = cheaper * lesser
additional = 0
if x - y > 0:
  additional = (x-y) * a
else:
  additional = (y-x) * b
total_p1 = base_cost + additional
total_p2 = moreer * double_c
print(min(total_p1, total_p2))

Submission status: Accepted

Solution code:
# ABC095C - Half and Half
def main():
    a, b, c, x, y = list(map(int, input().rstrip().split()))
    ans = min(
        c * 2 * max(x, y),
        a * x + b * y,
        c * 2 * y + a * max(0, x - y),
        c * 2 * x + b * max(0, y - x),
    )
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

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


ans = float("INF")
for i in range(10**5 + 1):
    val = 2*c*i + a*max(x-i, 0) + b*max(y-i, 0)
    ans = min(ans, val)


print(ans)

Submission status: Accepted

Solution code:
A, B, C, X, Y = map(int, input().split())
def calc(x, y):
    return A*x+B*y

mi = min(X, Y)
ma = max(X, Y)
print(min(calc(X,Y), calc(X-mi, Y-mi) + C*mi*2, C*ma*2))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math

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

cost = []
cost.append(A*X + B*Y)

for i in range(2*min(X,Y), 2*max(X,Y)+1):
    cost.append(C*i + max(0, math.ceil(X-i/2)*A) + max(0, math.ceil(Y-i/2)*B))

print(min(cost))

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:

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


ans = X * A + Y * B

bul = True

while bul:

    bul = False

    if X > 0 and Y > 0 and A + B > 2*C:

        bul = True
        X -= 1
        Y -= 1

        ans = ans - (A+B) + 2*C

    elif X > 0 and A > 2*C:

        bul = True
        X -= 1

        ans = ans - A + 2*C

    elif Y > 0 and B > 2*C:

        bul = True
        Y -= 1

        ans = ans - B + 2*C

print (ans)

Submission status: Accepted

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

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

print(ans)

Submission status: Accepted

Solution code:
# すげぇこんがらがるのでまずは落ち着く
# Cを使う場合とC"だけ"を遣う場合と使わない場合で分ける
a, b, c, x, y = map(int, input().split())
t = (x - y) * a if x > y else(y - x) * b
print(min(a * x + b * y, 2 * c * min(x, y) + t, 2 * c * max(x, y)))

Submission status: Accepted

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

ans = 10**9
for i in range(max(x,y)+1):
    cnt = 2*c*i
    if x > i:
        cnt += a*(x-i)
    if y >i:
        cnt += b*(y-i)
    ans = min(ans,cnt)

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(4100000)

a,b,c,x,y = [int(i) for i in input().split()]
cost = x * a
while y != 0:
    if x > 0:
        if c * 2 < a + b:
            cost += -a + c*2
            y -= 1
            x -= 1
        else:
            cost += b
            y -= 1
    else:
        if b < c * 2:
            cost += b
            y -= 1
        else:
            cost += c*2
            y -= 1
print(cost)

Submission status: Accepted

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

Submission status: Accepted

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

ab = c * 2

if ab < a and ab < b:
    print(max(x, y) * ab)
else:
    answer = min(a+b, ab) * min(x, y)

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

Submission status: Accepted

Solution code:
a,b,c,x,y = list(map(int,input().split()))
cost = []
tmp = 0
i = 0
# i == Cの数 (Cの倍額でA*1+B*1)
while i <= max(x,y) :
    tmp += i * 2 * c
    tmp += max(x-i,0)*a + max(y-i,0) * b
    cost.append(tmp)
    i += 1
    tmp = 0

print(min(cost))

Submission status: Accepted

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

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

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

  p=a*x+b*y
  q=c*2*max(x,y)

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

  return min(p,q,r)

print(main())

Submission status: Accepted

Solution code:
a, b, ab, xa, yb = map(int, input().split())
price = []
for i in range(100001):
    price.append(i * 2 * ab + max(xa - i, 0) * a + max(yb - i, 0) * b)

idx = price.index(min(price))

print(min(price))

Submission status: Accepted

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

mn_ABC = min(A+B, C*2)
mn_xy = min(X, Y)
money_1 = mn_ABC * mn_xy

money_2 = 0
if X > Y:
  mn_AC = min(A, C*2)
  money_2 = mn_AC * (X-Y)
elif X < Y:
  mn_BC = min(B, C*2)
  money_2 = mn_BC * (Y-X)

ans = money_1 + money_2
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A, B, C, X, Y = map(int, input().split())
mxy = max(X, Y)
ans = 10**10
for i in range(mxy+1):
    X_i = max(X-i, 0)
    Y_i = max(Y-i, 0)

    ans = min(C*i*2 + A*X_i + B*Y_i, ans)
print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

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

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

print (ans)

Submission status: Accepted

Solution code:
A, B, C, X, Y = map(int, input().split())
AB = [A, B]
XY = [X, Y]
ans = []
minXY = min(X, Y)
maxXY = max(X, Y)
maxid = XY.index(max(X, Y))

ans.append(A*X+B*Y)
print(min(A*X+B*Y, 2*C*minXY+(maxXY-minXY)*AB[maxid], maxXY*2*C))

Submission status: Accepted

Solution code:
#!/usr/bin/env python
a, b, c, x, y = map(int, input().split())
if a + b <= 2*c:
    ans = a*x+b*y
else:
    ans = 2 * c * min(x, y)
    if x >= y:
        add = min(a*(x-y), 2 * c * (x-y))
        ans += add
    else:
        add = min(b*(y-x), 2 * c * (y-x))
        ans += add

print(ans)

Submission status: Accepted

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

if c < a/2 and c < b/2:
    cost = max(x, y)*2*c
elif c < a/2:
    if x < y:
        cost = x*2*c + (y-x)*b
    else:
        cost = x*2*c
elif c < b/2:
    if y < x:
        cost = y*2*c + (x-y)*a
    else:
        cost = y*2*c
elif c < (a+b)/2:
    cost = min(x, y)*2*c+(x-min(x,y))*a + (y-min(x,y))*b
else:
    cost = x*a+y*b
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:
    z = min([x,y])
    ans = min([c*z*2+a*(x-z)+b*(y-z), c*max([x,y])*2])
    print(ans)

Submission status: Accepted

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

if a + b < c*2:
    res = a*x + b*y
else:
    min_c = min(x, y)
    ab_cost = min_c * 2 * c
    rem = max(x-min_c, y-min_c)
    if x > y:
        rem_cost = min(rem * a, rem*2*c)
    else:
        rem_cost = min(rem*b, rem*2*c)
    res = ab_cost + rem_cost
print(res)

Submission status: Accepted

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

ans = a*x + b*y

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

print(min(ans,max(x,y)*c*2))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

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

  l=[]
  l.append(a*x+b*y)
  l.append(c*x*2+b*max(0,y-x))
  l.append(c*y*2+a*max(0,x-y))
  l.append(c*max(x,y)*2)
  return min(l)

print(main())

Submission status: Accepted

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

Submission status: Accepted

Solution code:


def solve(A, B, C, X, Y):
    if A + B < C*2:
        return A * X + B * Y

    paid = 0
    if A > C * 2:
        #print("A > 2C")
        # A を買うより、C を 2 枚かったほうがお得
        paid += X * 2 * C
        Y -= X
        X = 0
    
    if Y > 0:
        if B > C * 2:
            #print("B > 2C", Y)
            paid += Y * 2 * C
            X -= Y
            Y = 0
        
    if X <= 0 and Y <= 0:
        return paid

    Z = min(X, Y)
    paid += Z * 2 * C
    X -= Z
    Y -= Z

    if X > 0:
        paid += X * A
    if Y > 0:
        paid += Y * B

    return paid

    



A, B, C, X, Y = [int(x) for x in input().split()]
# X : required of A
# Y : required of B
# A, B, C <= 10^5
print(solve(A, B, C, X, Y))

Submission status: Accepted

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

min_cost = float("inf")

for ab_pizza in range(0, max(x, y)*2+1, 2):
    cost = a * max(x - ab_pizza // 2, 0) + b * max(y - ab_pizza // 2, 0) + c * ab_pizza
    if cost < min_cost:
        min_cost = cost

print(min_cost)

Submission status: Accepted

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

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

Submission status: Accepted

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


check = 0
ans = 0
if 2 * C < A + B:
    #ABピザを買ったほうが良いケース（同数までは）
    ans += min(X, Y) * 2 * C
    if 2 * C < A and X - Y > 0:
        #最後のAの枚数調整でもCを買ったほうが良い場合
        ans += (X - Y) * 2 * C
    elif X - Y > 0:
        check = 1
    if 2 * C < B and Y - X > 0:
        #最後のBの枚数調整でもCを買ったほうが良い場合
        ans += (Y - X) * 2 * C
    elif Y - X > 0:
        check = 2
    if check == 1:
        #最後の枚数調整でAだけ個別に買ったほうが良い場合
        ans += (X - Y) * A
    elif check == 2:
        #最後の枚数調整でBだけ個別に買ったほうが良い場合
        ans += (Y - X) * B
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 >2*c:
    mini = min(x,y) #ABセットで揃えられる枚数
    ab_cost = mini * 2 * c
    remain = max(x-mini, y-mini)
    if x > y:
        remain_cost = min(remain * a, remain*2*c)
    else:
        remain_cost = min(remain * b, remain*2*c)
    print(ab_cost + remain_cost)
else:
    print(a*x+b*y)

Submission status: Accepted

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

if (a + b) <= c * 2:
  cost_over = 10 ** 100
  cost = a * x + b * y 
else: 
  if x <= y:
    cost_over = c * 2 * y
    cost = c * 2 * x + b * (y - x)
  else: 
    cost_over = c * 2 * x
    cost = c * 2 * y + a * (x - y)

min = min(cost, cost_over)
print(min)

Submission status: Accepted

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

answer = 10**18
for c in range(10**5+1):
  a = X-c
  b = Y-c
  cost = C*c*2
  cost += max(a,0)*A
  cost += max(b,0)*B
  if answer > cost:
    answer = cost
print(answer)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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


def solve(A: int, B: int, C: int, X: int, Y: int):
    cost = float("inf")

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

    print(cost)



# Generated by 1.1.4 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=list(map(int,input().split()))
ans=0
if (A+B)/2>=C:
    ans+=2*C*min(X,Y)
else:
    ans+=(A+B)*min(X,Y)

if X>=Y and A>=2*C:
    ans+=2*C*abs(X-Y)
elif X>=Y:
    ans+=A*abs(X-Y)
elif X<Y and B>=2*C:
    ans+=2*C*abs(X-Y)
else:
    ans+=B*abs(X-Y)
print(ans)

Submission status: Accepted

Solution code:
def smaller(x, y):
	if x < y: return x
	return y
A, B, C, X, Y = map(int, raw_input().split())
sum = 0
if A+B > 2 * C:
	c = smaller(X, Y)
	sum += c * 2 * C
	X -= c
	Y -= c
	if A > 2 * C: sum += X * 2 * C
	else: sum += X * A
	if B > 2 * C: sum += Y * 2 * C
	else: sum += Y * B
else:
	sum = A * X + B * Y
print sum

Submission status: Accepted

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

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

Submission status: Accepted

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

a_pizza = a * x
b_pizza = b * y
ans_1 = a_pizza + b_pizza

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

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

print(min(ans_1, ans_2, ans_3))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A, B, C, X, Y = map(int, open(0).read().split())
ans = 0
res = 0
if A + B > C * 2:
    ans += C * min(X, Y) * 2
    res = X - Y
else:
    ans += A * X + B * Y
    
if res > 0:
    ans += min(A * res, C * res * 2)
elif res < 0:
    ans += min(B * abs(res), C * abs(res) * 2)
    
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
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)))

Submission status: Accepted

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

Submission status: Accepted

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

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

print (ans)

Submission status: Accepted

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

ans = 0
if A <= C and B <= C: #A, Bの値段がCよりも安い-->素直にA, Bのみを買う
    ans = A * X + B * Y
elif A > C and B > C: #Cの値段がA, Bのどちらよりも安い
    if X > Y: #Aの必要枚数のほうが多い
        zan = (X-Y) * A
    else: #Bの必要枚数のほうが多い
        zan = (Y-X) * B
    ans = min(X, Y) * 2 * C + min(zan, C * (max(X, Y)- min(X, Y)) * 2) #残り枚数をA or Bで買うか、余るのを覚悟してABを買うか
else:
    if X > Y: #Xのほうが枚数多い
        ans = A * X + B * Y #素直に買う
        kari = Y * 2 * C + A * (X-Y) #余らないようにできるだけCを買う
        ans = min(ans, kari)
        kari = X * 2 * C #余ってもいいからCを買う
        ans = min(ans, kari)
    else: #X <= Y
        ans = A * X + B * Y
        kari = X * 2 * C + B * (Y-X)
        ans = min(ans, kari)
        kari = Y * 2 * C
        ans = min(ans, kari)
print (ans)

Submission status: Accepted

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

Submission status: Accepted

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


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

    else:
        ret += A * X + B * Y
    print(ret)
    return


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())
cost=0
pizza_rem=0

#C買いまくってAを満たす場合(2C<A)
if 2*C<=A:
    cost+=2*C*X
    pizza_rem=Y-X
    if pizza_rem<=0:
        print(cost)
    else:
        cost+=min(2*C,B)*pizza_rem
        print(cost)

#C買いまくってBを満たす場合(2C<B)
elif 2*C<=B:
    cost+=2*C*Y
    pizza_rem=X-Y
    if pizza_rem<=0:
        print(cost)
    else:
        cost+=min(2*C,A)*pizza_rem
        print(cost)

#min(X,Y)枚Cを買う場合(A,B<2C<A+B)
elif 2*C<A+B:
    cost+=2*C*min(X,Y)
    pizza_rem=abs(X-Y)
    if X<Y:
        cost+=B*pizza_rem
        print(cost)
    else:
        cost+=A*pizza_rem
        print(cost)
        
#AとBをバラバラで買ったほうが安い場合
else:
    cost+=A*X+B*Y
    print(cost)

Submission status: Accepted

Solution code:
#ABC095-C
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(input())
def S(): return list(input())
a,b,c,x,y=IL()
c=c*2
if c<=a:
    if c<=b:
        print(c*max(x,y))
    else:
        print(c*x+max(0,(y-x)*b))
elif c<=b:
    print(c*y+max(0,(x-y)*a))
elif c<=a+b:
    if x>=y:
        print(c*y+a*(x-y))
    else:
        print(c*x+b*(y-x))
else:
    print(a*x+b*y)

Submission status: Accepted

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

total = 0
share = min(X, Y)
X -= share
Y -= share
if A+B <= 2*C:
    total += share * (A+B)
else:
    total += share * 2 * C

if X > 0:
    if A < 2 * C:
        total += A * X
    else:
        total += 2 * C * X

if Y > 0:
    if B < 2 * C:
        total += B * Y
    else:
        total += 2 * C * Y

print(total)