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: Wrong Answer

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

ans2 = x*a + y*b

ab = max(x, y)//2 * 2
ans3 = ab*2*c + max(0, x-ab)*a + max(0, y-ab)*b

ab = max(x, y)//2 * 2
ans4 = ab*2*c + max(0, x-ab)*a + max(0, y-ab)*b
print(min(ans1, ans2, ans3, ans4))

Submission status: Wrong Answer

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

ans2 = x*a + y*b

ab = max(x, y)/2 * 2
ans3 = ab*2*c + max(0, x-ab)*a + max(0, y-ab)*b
print(min(ans1, ans2, ans3))

Submission status: Wrong Answer

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

ans2 = x*a + y*b

ab = max(x, y)//2 * 2
ans3 = ab*2*c + max(0, x-ab)*a + max(0, y-ab)*b
print(min(ans1, ans2, ans3))

Submission status: Wrong Answer

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

ans = float('inf')
for i in range(0, 2 * max(x, y)+1, 2):
    if min((x - (i // 2)), (y - (i // 2))) < 0:
        break
    #合計費用
    total = a * (x - (i // 2)) + b *(y - (i // 2)) + c * i
    ans = min(ans, total)
print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

def main():
    a, b, c, x, y = map(int, input().split())
    ans = INF*max(a, b, c)
    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()

Submission status: Wrong Answer

Solution code:
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(ans, a*max(0,x-i/2)+b*max(0,y-i/2)+c*i)
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:


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

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

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

print(ans)

Submission status: Wrong Answer

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

if A+B < 2*C:
    print(A*X+B*Y)
else:    #ABピザを二枚ずつ増やしていく
    ans = float('inf')
    for i in range(0,max(X,Y)*2+1,2):
        ans = min(ans, max((X-i//2), 0)+max(B*(Y-i//2),0) + C*i)
    print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def LI(): return list(map(int,input().split()))
A,B,C,X,Y = LI()
ans = min(A*X+B*Y,C*(max(X,Y)*2))
if min(X,Y)%2==0:
    temp = (min(X,Y)*2)*C + (max(X,Y)-min(X,Y))*(A if X>Y else B)
    ans = min(temp,ans)
print(ans)

Submission status: Wrong Answer

Solution code:
def halfandhalf(A,B,C,X,Y):
    if X >= Y:
        if A+B > 2*C:
            sum = C*2*Y + A*(X-Y)
        else:
            sum = A*X + B*Y
        
    else:
        if A+B > 2*C:
            sum = C*2*X + B*(Y-X)
        else:
            sum = A*X + B*Y
    return sum




if __name__ == "__main__":
    A,B,C,X,Y = map(int, input().split())
    print(halfandhalf(A,B,C,X,Y))

Submission status: Wrong Answer

Solution code:
def halfandhalf(A,B,C,X,Y):
    if X >= Y:
        if A+B > 2*C:
            sum = C*2*Y + A*(X-Y)
        else:
            sum = A*X + B*Y
        
    else:
        if A+B > 2*C:
            sum = C*2*X + B*(Y-X)
        else:
            sum = A*X + B*Y
    return sum




if __name__ == "__main__":
    A,B,C,X,Y = map(int, input().split())
    print(halfandhalf(A,B,C,X,Y))

Submission status: Wrong Answer

Solution code:
#from math import gcd

from math import factorial as f

from math import ceil,floor,sqrt


import bisect
import re
import heapq


from copy import deepcopy
import itertools

from sys import exit

ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

yes = "Yes"
no = "No"

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


main()

Submission status: Wrong Answer

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

if a > 2*c and b > 2*c: #Aピザを買うならABピザを2枚買った方が安いかつBピザを買うならABピザを2枚買った方が安い場合
    ans += max(x,y)*2*c #ABピザを枚数の多い方に合わせて買う

elif a > 2*c: #Aピザを買うならABピザを2枚買った方が安い(Bピザは違う)場合
    ans += x*2*c
    if y > x:
        ans += (y-x)*b

elif b > 2*c: #Bピザを買うならABピザを2枚買った方が安い(Aピザは違う)場合
    ans += y*2*c
    if x > y:
        ans += (x-y)*a

else: #そうでない場合
    if (a+b)//2 > c: #AピザとBピザの平均がABピザより高い場合
        z = min(x,y)
        ans += z*2*c
        x -= z
        y -= z
        if x > y:
            ans += x*a
        else:
            ans += y*b 

    else: #AピザとBピザの平均がABピザより安い場合
        ans = x*a + y*b

print(ans)

Submission status: Wrong Answer

Solution code:
A,B,C,X,Y = map(int,input().split())
cnt_A = X
cnt_B = Y
cnt_C = 0
ans = []
for _ in range(X+Y):
    if 2*C<=A+B:
        cnt_C += 2
        cnt_A -= 1
        cnt_B -= 1
    ans.append(cnt_A*A+cnt_B*B+cnt_C*C)
    if ((cnt_A<0) or (cnt_B<0)) or ((cnt_C==2*X)or(cnt_C ==Y*22)):
        break  
ans.sort()
print(ans[0])

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math

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

for c in range(max(X, Y) * 2 + 1):
    a = math.ceil(X - 0.5 * c) if X - 0.5 * c >= 0 else 0
    b = math.ceil(Y - 0.5 * c) if Y - 0.5 * c >= 0 else 0
    m = min(a * A + b * B + c * C, m)
    print(a, b, c)

print(m)

Submission status: Wrong Answer

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

s1 = a*x + b*y
s2 = c*(max(x,y)*2)
if x>y:
    s3 = c*(y*2) + a*(x-y)
elif y>x:
    s3 = c*(x*2) + b*(y-x)
else: s3 = 10**10

print(s1,s2,s3)
print(min(s1,s2,s3))

Submission status: Wrong Answer

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

pat1 = 0
pat2 = 0
pat3 = 0
pat4 = 0
pat5 = 0

ans = []

if a+b >= c*2:
  if x >= y:
    pat1 = y * 2 * c
    x -= y
    pat1 += x * a 
    x += y
    
    pat2 = x * 2 * c
    
  if x <= y:
    pat3 = x * 2 * c
    y -= x
    pat3 += x * a + y * b
    y += x
    
    pat4 = y * 2 * c
elif a+b <= c*2:
  pat5 += x * a + y * b

ans.extend([pat1, pat2, pat3, pat4, pat5])
ans = [i for i in ans if i!= 0]
  
print(min(ans))

Submission status: Wrong Answer

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

pat1 = 0
pat2 = 0
pat3 = 0
pat4 = 0
pat5 = 0

ans = []

if a+b >= c*2:
  if x >= y:
    pat1 = y * 2 * c
    x -= y
    pat1 += x * a 
    x += y
    
    pat2 = x * 2 * c
    
  else:
    pat3 = x * 2 * c
    y -= x
    pat3 += x * a + y * b
    y += x
    
    pat4 = y * 2 * c
else:
  pat5 += x * a + y * b

ans.extend([pat1, pat2, pat3, pat4, pat5])
ans = [i for i in ans if i!= 0]
  
print(min(ans))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a, b, c, x, y = map(int, input().split())
n = a*x + b*y
sx, rx = divmod(x, 2)
sy, ry = divmod(y, 2)
s = 2*min(sx, sy)
m = 2*c*s + a*(2*sx-s+rx) + b*(2*sy-s+ry)
print(min(n, m))

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans = 0

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

print(ans)

Submission status: Wrong Answer

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

ans = 0

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

print(ans)

Submission status: Wrong Answer

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

ans = 0

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

print(ans)

Submission status: Wrong Answer

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

ans = 0

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

print(ans)

Submission status: Wrong Answer

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

ans = A*X+B*Y
for i in [0, 1, max(1,A-1), max(1,X)]:
    for j in [0, 1, max(1,B-1), max(1,Y)]:
        ab = max(X-i, Y-j)
        ans = min(ans, A*i + B*j + C*(2*ab))
print(ans)

Submission status: Wrong Answer

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

ans = A*X+B*Y
for i in [0, 1, max(1,A-1), max(1,A)]:
    for j in [0, 1, max(1,B-1), max(1,B)]:
        ab = max(X-i, Y-j)
        ans = min(ans, A*i + B*j + C*(2*ab))
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

for i in range(x+y):
    if i%2!=0:
        continue
    if (i//2)>=x:
        a_p = 0
        b_p = b*(y-(i//2))
    if (i//2)>=y:
        a_p = a*(x-(i//2))
        b_p = 0
    else:
        a_p = a*(x-(i//2))
        b_p = b*(y-(i//2))
        
    price = (c*i)+ a_p + b_p
    l.append(price)

print(min(l))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a,b,c,x,y=map(int,input().split())
d=(a+b)/2
import sys
o=x
w=y
count=0
if d>=c:
    if x>=y:
        r=x
        
        x-=y
        y=0
        count+=((r-x)*2*c)
        count+=(x*a)
        print(min(count,(o*2*c)))
        sys.exit()
      

    else:
        r=y
        
        y-=x
        x=0
        count+=((r-y)*2*c)
  
        count+=(x*a)
        
        
        print(min(count,w*2*c))
        sys.exit()
    
        
else:
    count+=a*x+b*y    
    print(count)

Submission status: Wrong Answer

Solution code:
a,b,c,x,y=map(int,input().split())
d=(a+b)/2
import sys
o=x
w=y
count=0
if d>=c:
    if x>=y:
        r=x
        
        x-=y
        y=0
        count+=((r-x)*2*c)
        count+=(x*a)
        print(min(count,(o*2*c)))
        sys.exit()
      

    else:
        r=y
        
        y-=x
        x=0
        count+=((r-y)*2*c)
        count+=(x*a)
        print(min(count,y*2*c))
        sys.exit()
    
        
else:
    count+=a*x+b*y    
    print(count)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

# ABセットをi個購入したとき、Aをmax(0, x - i)個、Bをmax(0, y - i)個購入する必要がある
# 1 <= x, y <= 10^5なので、全探索して最小金額を求めればよい

inf = float("inf")
min_price = inf
max_i = 10 ** 5

for i in range(max_i):
    rest_x, rest_y = max(0, x - i), max(0, y - i)
    price = 2 * c * i + a * rest_x + b * rest_y
    if price < min_price:
        min_price = price

print(min_price)

Submission status: Wrong Answer

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

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

total = 0
if a + b >= 2 * c:
    # A, Bセットを買う方が得
    if x > y:
        total += 2 * c * y
        rest = x - y
        if b > 2 * c:
            # Aの残りもA, Bセットを買う方が得
            total += 2 * c * rest
        else:
            total += a * rest
    elif x < y:
        total += 2 * c * x
        rest = y - x
        if a > 2 * c:
            # Bの残りもA, Bセットを買う方が得
            total += 2 * c * rest
        else:
            total += b * rest
    else:
        # x == y
        total += 2 * c * x
else:
    # a + b < 2 * c
    # A, Bそれぞれ買う方が得
    total += a * x + b * y

print(total)

Submission status: Wrong Answer

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

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

total = 0
if a + b >= 2 * c:
    # A, Bセットを買う方が得
    if x > y:
        total += 2 * c * y
        rest = x - y
        if b >= 2 * c:
            # Aの残りもA, Bセットを買う方が得
            total += 2 * c * rest
        else:
            total += a * rest
    elif x < y:
        total += 2 * c * x
        rest = y - x
        if a >= 2 * c:
            # Bの残りもA, Bセットを買う方が得
            total += 2 * c * rest
        else:
            total += b * rest
    else:
        # x == y
        total += 2 * c * x
else:
    # a + b < 2 * c
    # A, Bそれぞれ買う方が得
    total += a * x + b * y

print(total)

Submission status: Wrong Answer

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

ans1 = int(A*X + B*Y)
ans2 = int(C*X + (Y-X)*B)
ans3 = int(C*Y + (X-Y)*A)

print(min(ans1,ans2,ans3))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

Solution code:
import itertools
import math
import sys
import heapq
from collections import Counter
from collections import deque
from fractions import gcd
INF = 1 << 60
sys.setrecursionlimit(10 ** 6)

#ここから書き始める
a, b, c, x, y = map(int, input().split())
ans = min((a + b) * min(x, y), c * min(x, y) * 2)
if x > y:
    ans += min(a * (x - y), c * (x - y) * 2)
else:
    ans += min(a * (y - x), c * (y - x) * 2)
print(ans)

Submission status: Wrong Answer

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

res = -1
for i in range(0, 10 ** 5):
  cand = i * 2 * c + max(0, x - i) * a + max(0, y - i) * b
  if res == -1:
    res = cand
  else:
    if res > cand:
      res = cand
print(res)

Submission status: Wrong Answer

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

if 2 * c <= (a + b):
  min_ = min((x // 2), (y // 2))
  res1 = 4 * min_ * c + a * (x - 2 * min_) + b * (y - 2 * min_)
  if x > y:
    if x % 2 != 0:
      res2 = min(2 * x * c + a * (x % 2), 2 * (x + 1) * c)
    else:
      res2 = 2 * x * c
  else:
    if y % 2 != 0:
      res2 = min(2 * y * c + b * (y % 2), 2 * (y + 1) * c)
    else:
      res2 = 2 * y * c
  print(min(res1, res2)) 
else:
  print(a * x + b * y)

Submission status: Wrong Answer

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

if 2 * c < (a + b):
  min_ = min((x // 2), (y // 2))
  res1 = 4 * min_ * c + a * (x - 2 * min_) + b * (y - 2 * min_)
  if x > y:
    if x % 2 != 0:
      res2 = min(2 * x * c + a * (x % 2), 2 * (x + 1) * c)
    else:
      res2 = 2 * x * c
  else:
    if y % 2 != 0:
      res2 = min(2 * y * c + b * (y % 2), 2 * (y + 1) * c)
    else:
      res2 = 2 * y * c
  print(min(res1, res2))
else:
  print(a * x + b * y)

Submission status: Wrong Answer

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 = C*i + A*max(0, X-i) + B*max(0, Y-i)
  ans = min(ans, price)

print(ans)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Tue Mar 31 12:25:45 2020

@author: black
"""

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


a_num = 0
b_num = 0
c_num = 0
P_MIN = min(A, B)
MAX = max(X, Y)

ans = 10**10
if 2*C < 2*P_MIN:
    a_num = 0
    b_num = 0
    c_num = MAX*2
    ans = A*a_num + B*b_num + C*c_num
else:
    for i in range(X+1):
        for j in range(Y+1):
            for k in range(max(X,Y)):
                if i+k>=X and j+k>=Y:
                    a_num = i
                    b_num = j
                    c_num = k*2
                    total = A*a_num + B*b_num + C*c_num
                    ans = min(total, ans)

print(ans)

Submission status: Wrong Answer

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

@author: black
"""


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


a_num = X
b_num = Y
c_num = 0
total = A*a_num + B*b_num + C*c_num

ans = 10**10
P_MAX = max(A,B)
P_MIN = min(A, B)
MAX = max(X, Y)
MIN = min(X, Y)

if 2*C >= 2*P_MAX:
    ans = total
elif 2*P_MAX > 2*C and 2*C > A + B:
    for i in range(MAX+1):
        a_num = X-i
        b_num = Y-i
        c_num = 2*i
        T = A*a_num + B*b_num + C*c_num
        total = min(total, T)
elif A + B >= 2*C and 2*C > 2*P_MIN:
    c_num = MIN*2
    if A>B:
        a_num = 0
        b_num = Y-MIN
        total = A*a_num + B*b_num + C*c_num
    else:
        a_num = X-MIN
        b_num = 0
        total = A*a_num + B*b_num + C*c_num
else:
    a_num = 0
    b_num = 0
    c_num = MAX*2
    total = A*a_num + B*b_num + C*c_num
ans = total
print(ans)

Submission status: Wrong Answer

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

@author: black
"""


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


a_num = X
b_num = Y
c_num = 0
total = A*a_num + B*b_num + C*c_num

ans = 10**10
P_MAX = max(A,B)
P_MIN = min(A, B)
MAX = max(X, Y)
MIN = min(X, Y)

if 2*C >= 2*P_MAX:
    ans = total
elif 2*P_MAX > 2*C and 2*C > A + B:
    for i in range(MIN, MAX+1):
        a_num = X-i
        b_num = Y-i
        c_num = 2*i
        T = A*a_num + B*b_num + C*c_num
        total = min(total, T)
elif A + B >= 2*C and 2*C > 2*P_MIN:
    c_num = MIN*2
    if A>B:
        a_num = 0
        b_num = Y-MIN
        total = A*a_num + B*b_num + C*c_num
    else:
        a_num = X-MIN
        b_num = 0
        total = A*a_num + B*b_num + C*c_num
else:
    a_num = 0
    b_num = 0
    c_num = MAX*2
    total = A*a_num + B*b_num + C*c_num
ans = total
print(ans)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Tue Mar 31 10:33:57 2020

@author: black
"""


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


a_num = X
b_num = Y
c_num = 0
total = A*a_num + B*b_num + C*c_num

ans = 10**10
if A + B <= 2*C:
    ans = total
elif min(A, B)*2 >= 2*C:
    a_num = 0
    b_num = 0
    c_num = max(X, Y)*2
    ans = C*c_num
elif A + B > 2*C and 2*C > min(A, B)*2:
    MAX = max(X,Y)
    MIN = min(X,Y)
    for i in range(MIN, MAX+1):
        a_num = max(X-i, 0)
        b_num = max(Y-i, 0)
        c_num = 2*i
        total = A*a_num + B*b_num + C*c_num
        print(a_num, b_num, c_num)
print(ans)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Tue Mar 31 10:33:57 2020

@author: black
"""


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


a_num = X
b_num = Y
c_num = 0
total = A*a_num + B*b_num + C*c_num

ans = 10**10
if A + B <= 2*C:
    ans = total
elif min(A, B) * 2 >= 2 * C:
    a_num = 0
    b_num = 0
    c_num = max(X, Y)
    ans = C*c_num
elif A + B > 2*C and 2*C > min(A, B)*2:
    MAX = max(X,Y)
    MIN = min(X,Y)
    for i in range(MIN, MAX+1):
        a_num = max(X-i, 0)
        b_num = max(Y-i, 0)
        c_num = 2*i
        total = A*a_num + B*b_num + C*c_num
        ans = min(ans, total)
print(ans)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Tue Mar 31 10:33:57 2020

@author: black
"""


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


a_num = X
b_num = Y
c_num = 0
total = A*a_num + B*b_num + C*c_num

ans = 10**9
if A + B <= 2*C:
    ans = total
elif min(A, B) * 2 >= 2 * C:
    a_num = 0
    b_num = 0
    c_num = max(A, B)
    ans = C*c_num
elif A + B > 2*C and 2 * C > min(A, B) * 2:
    MAX = max(X,Y)
    MIN = min(X,Y)
    for i in range(MIN, MAX+1):
        a_num = max(X-i, 0)
        b_num = max(Y-i, 0)
        c_num = 2*i
        total = A*a_num + B*b_num + C*c_num
        ans = min(ans, total)
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Tue Mar 31 10:33:57 2020

@author: black
"""


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


a_num = X
b_num = Y
c_num = 0
total = A*a_num + B*b_num + C*c_num

ans = 10**9
if A + B < 2*C:
    ans = total
elif min(A, B) * 2 < 2 * C and A + B < 2*C:
    MAX = max(X,Y)
    MIN = min(X,Y)
    for i in range(MIN, MAX+1):
        a_num = max(X-i, 0)
        b_num = max(Y-i, 0)
        c_num = 2*i
        total = A*a_num + B*b_num + C*c_num
        ans = min(ans, total)
elif min(A, B) * 2 > 2 * C:
        a_num = 0
        b_num = 0
        c_num = max(A, B)
        ans = C*c_num

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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: Wrong Answer

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

plan_P = A*X + B*Y

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

if (A + B) <= 2 * C:
  print(plan_P)
else:
  print(plan_Q)

Submission status: Wrong Answer

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

plan_P = A*X + B+Y

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

if (A + B) <= 2 * C:
  print(plan_P)
else:
  print(plan_Q)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
A,B,C,X,Y = map(int,input().split())
X_piza = X
Y_piza = Y
minimum = 10**20
for i in range(0,10**5+2,2):
  if minimum>C*2*i+max(0,X-i)*A+max(0,Y-i)*B:
    minimum = C*2*i+max(0,X-i)*A+max(0,Y-i)*B
print(minimum)

Submission status: Wrong Answer

Solution code:
A,B,C,X,Y = map(int,input().split())
X_piza = X
Y_piza = Y
minimum = 10**10
for i in range(0,10**5+2,2):
  if minimum>C*2*i+max(0,X-i)*A+max(0,Y-i)*B:
    minimum = C*2*i+max(0,X-i)*A+max(0,Y-i)*B
print(minimum)

Submission status: Wrong Answer

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

if c<a/2 and c<b/2:
    print(c*max(x,y)*2)
elif (a+b)/2 < c:
    print(a*x + b*y)
else:
    if x<y:
        print(c*2*x + b*(y-x))
    else:
        print(c*2*y + a*(x-y))

Submission status: Wrong Answer

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)*A)
result.append(X*A+Y*B)
print(min(result))