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:
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    s = S()
    s.append("o")
    a = s.count("o")-1
    print(700+a*100)
    return

#B
def B():
    n, x = LI()
    m = IR(n)
    m.sort()
    msum = sum(m)
    print(n + (x - msum) // m[0])
    return

#C
def C():
    a, b, c, x, y = LI()
    if c * 2 > a + b:
        print(x * a + y * b)
        return
    if x > y:
        if c * 2 > a:
            print(c * 2 * y + (x - y) * a)
            return
        print(c * 2 * x)
        return
    print(c * 2 * x + (y - x) * b)
    return

#D
def D():
    return

#Solve
if __name__ == '__main__':
    C()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

ans1 = A*X + B*Y
ans2 = 0
ans3 = 0
if X >= Y:
  ans2 = A*(X-Y) + AB*Y*2
  ans3 = AB*X*2
else:
  ans2 = A*(Y-X) + AB*X*2
  ans3 = AB*Y*2
print(min(ans1, ans2, ans3))

Submission status: Wrong Answer

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

ans1 = A*X + B*Y
ans2 = 0
ans3 = 0
if X >= Y:
  ans2 = A*(X-Y) + AB*Y
  ans3 = AB*X
else:
  ans2 = A*(Y-X) + AB*X
  ans3 = AB*Y
print(min(ans1, ans2, ans3))

Submission status: Wrong Answer

Solution code:
A, B, C, X, Y = map(int, input().split())
count_a = 0
count_b = 0
count_ab = 0
if C <= A and C <= B:
    max_num = X if X >= Y else Y
    while count_ab / 2 != max_num:
        count_ab += 1
    print(C * count_ab)
    exit()

if A <= C and B <= C:
    print(A * X + B * Y)
else:
    while count_ab / 2 != X and count_ab / 2 != Y:
        count_ab += 1
    count_a = count_ab / 2
    count_b = count_ab / 2
    add_count_a, add_count_b = 0, 0
    while count_a + add_count_a != X:
        add_count_a += 1
    while count_b + add_count_b != Y:
        add_count_b += 1
    print(A * add_count_a + B * add_count_b + C * count_ab)

Submission status: Wrong Answer

Solution code:
A, B, C, X, Y = map(int, input().split())
ave_ab = (A + B) / 2
count_a = 0
count_b = 0
count_ab = 0
if C <= A and C<= B:
    max_num = X if X >= Y else Y
    while count_ab / 2 != max_num:
        count_ab += 1
    print(C * count_ab)
    exit()

if ave_ab > C:
    while count_ab / 2 != X and count_ab / 2 != Y:
        count_ab += 1
    count_a = count_ab / 2
    count_b = count_ab / 2
    add_count_a, add_count_b = 0, 0
    while count_a + add_count_a != X:
        add_count_a += 1
    while count_b + add_count_b != Y:
        add_count_b += 1
    print(A * add_count_a + B * add_count_b + C * count_ab)
else:
    print(A * X + B * Y)

Submission status: Wrong Answer

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


Set = min(X, Y)

if A+B >= 2*C:
    ans = Set * C * 2
    X -= Set
    Y -= Set
    big = max(X, Y)
    ans += min(A*X+B*Y, (big//2+big%2)*4*C)
else:
    ans = A*X + B*Y

print(ans)

Submission status: Wrong Answer

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


Set = min(X, Y)

if A+B >= 2*C:
    ord = (Set // 2) * 2
    ans = ord * C * 2
    X -= ord
    Y -= ord
    big = max(X, Y)
    ans += min(A*X+B*Y, (big//2+big%2)*4*C)
else:
    ans = A*X + B*Y

print(ans)

Submission status: Wrong Answer

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

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

if A > 2*C:
    A = 2*C
    Y = max(Y - X, 0)
elif B > 2*C:
    B = 2*C
    X = max(X - Y, 0)

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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*abs(X-(i//2)) + B*abs(Y-(i//2)) + i*C
    #print(total,i)
    if total > 0 and total < ans:
        ans = total
print(ans)

Submission status: Wrong Answer

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*(X-(i//2)) + B*(Y-(i//2)) + i*C
    #print(total)
    if total > 0 and total < ans:
        ans = total
print(ans)

Submission status: Wrong Answer

Solution code:
from sys import stdin
A,B,C,X,Y = [int(x) for x in stdin.readline().rstrip().split()]
if A + B <= 2*C:
    ans = A*X + B*Y
    
elif A > 2*C and B > 2*C:
    ans = C*2*max(X,Y)
 
elif A > B:
    ans = 2*C*X + B*max(Y-X,0)
 
elif B > A:
    ans = A*max(X-Y,0) + 2*C*Y

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

Submission status: Wrong Answer

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) * B

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

print(min(ans_1, ans_2))

Submission status: Wrong Answer

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()
	
	if X < Y:
		if A <= C:
			part1 = A*X
			part21 = C*2*Y
			part22 = B*Y
			tmp = min(part21,part22)
			tmp = part1 + tmp
			print(min(base, tmp))
			sys.exit()
				
		else:
			part1 = C*2*X
			Y -= X
			part21 = C*2*Y
			part22 = B*Y
			tmp = min(part21,part22)
			tmp = part1 + tmp
			print(min(base, tmp))
			sys.exit()
	else:
		if B <= C:
			part1 = B*Y
			part21 = C*2*X
			part22 = A*X
			tmp = min(part21,part22)
			tmp = part1 + tmp
			print(min(base, tmp))
			sys.exit()
				
		else:
			part1 = C*2*Y
			X -= Y
			part21 = C*2*X
			part22 = A*X
			tmp = min(part21,part22)
			tmp = part1 + tmp
			print(min(base, tmp))
			sys.exit()
			
	
if __name__ == "__main__":
	main()

Submission status: Wrong Answer

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(base_cost, additional)
print(min(total_p1, total_p2))

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

    print(ans)

Submission status: Wrong Answer

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)
    rest = max(x, y) - min(x, y)
    rest = rest * a if x > y else rest * b
    print(answer + rest)

Submission status: Wrong Answer

Solution code:
from sys import stdin
A,B,C,X,Y = [int(x) for x in stdin.readline().rstrip().split()]
if A + B <= 2*C:
    ans = A*X + B*Y
    
elif A > 2*C and B > 2*C:
    ans = C*2*max(X,Y)
 
elif A > B:
    ans = 2*C*X + B*max(Y-X,0)
 
elif B >= A:
    ans = A*max(X-Y,0) + 2*C*Y

print(ans)

Submission status: Wrong Answer

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

print(min(cost))

Submission status: Wrong Answer

Solution code:
a, b, ab, xa, yb = map(int, input().split())
price = []
for i in range(1, 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: Wrong Answer

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

print(min(price))

Submission status: Wrong Answer

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

print(min(price))

Submission status: Wrong Answer

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

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:
    ans += 2*C*min(X, Y)

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

print (ans)

Submission status: Wrong Answer

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

if A + B <= 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) * (X-Y)

print (ans)

Submission status: Wrong Answer

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

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

print (ans)

Submission status: Wrong Answer

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)
    res = min_c*2*c + max(0, x-min_c)*a + max(0, y-min_c)*b 

print(res)

Submission status: Wrong Answer

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)
    max_c = max(x, y)
    diff = max_c - min_c
    odd = min_c % 2
    res = (min_c * 2) * c + (diff-odd)*max(a, b)

print(res)

Submission status: Wrong Answer

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)
    max_c = max(x, y)
    diff = max_c - min_c
    res = (min_c * 2) * c + diff*max(a, b)

print(res)

Submission status: Wrong Answer

Solution code:
a,b,c,x,y=map(int,input().split())
ans=9**9
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: Wrong Answer

Solution code:
a,b,c,x,y=map(int,input().split())
ans=9**9
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: Wrong Answer

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
            Y = 0
            X -= Y
        
    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: Wrong Answer

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

Submission status: Wrong Answer

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 * min(x, y) + a * abs(x - y),
    c * 2 * min(x, y) + b * abs(y - x),
)
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)
elif C < min(A, B):
  print(max(X, Y) * 2 * C)
else:
  print(min(X, Y) * 2 * C + (A if X > Y else B) * abs(X-Y))

Submission status: Wrong Answer

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(C * res, A * res)
elif res < 0:
    ans += min(B * res, A * res)
    
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)
elif x<y:
	print(c*2*x+b*(y-x))
else:
	print(c*2*y+a*(x-y))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

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

print(ans)

Submission status: Wrong Answer

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

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

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

print(ans)

Submission status: Wrong Answer

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

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

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
from collections.abc import Iterable
from math import *
from itertools import *
from collections import *
from functools import *
from operator import *
try:
    from math import gcd
except Exception:
    from fractions import gcd


def solve(A: int, B: int, C: int, X: int, Y: int):
    a = A * X + B * Y
    minv = min(X, Y)
    eminv = 2 * (minv // 2)
    b = C * 2 * eminv + A * (X - eminv) + B * (Y - eminv)

    eminv2 = 2 * ((minv + 1) // 2)
    c = C * 2 * eminv2 + A * max((X - eminv2), 0) + B * max((Y - eminv2), 0)

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

    return min(a, b, c, d)


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
    result = solve(A, B, C, X, Y)
    if isinstance(result, Iterable):
        result = '\n'.join([str(v) for v in result])
    print(result)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

if ab < A / 2:
    buy_c = X * 2
    ans += buy_c * ab
    X -= buy_c
    Y -= buy_c

if ab < B / 2:
    buy_c = Y
    ans += buy_c * ab
    X -= buy_c
    Y -= buy_c

if ab < A:
    buy_c = (X // 2) * 2
    ans += buy_c * ab
    X -= buy_c

if ab < B:
    buy_c = (Y // 2) * 2
    ans += buy_c * ab
    Y -= buy_c

ans += A * X + B * Y

print(ans)

Submission status: Wrong Answer

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

if ab < A:
    buy_c = (X // 2) * 2
    ans += buy_c * ab
    X -= buy_c

if ab < B:
    buy_c = (Y // 2) * 2
    ans += buy_c * ab
    Y -= buy_c

ans += A * X + B * Y

print(ans)

Submission status: Wrong Answer

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

for i in range(1,10**5):
  sum = C*2*i + max(0,X-i)*A + max(0,Y-i)*B
  MIN = min(MIN,sum)
print(MIN)

Submission status: Wrong Answer

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

for i in range(10**5):
  sum = C*2*i + max(0,X-i)*A + max(0,Y-i)*B
  MIN = min(MIN,sum)
print(MIN)

Submission status: Wrong Answer

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

for i in range(10^5):
  sum = C*2*i + max(0,X-i)*A + max(0,Y-i)*B
  MIN = min(MIN,sum)
print(MIN)

Submission status: Wrong Answer

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

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:
    c = min(X, Y)
    x = X-c
    y = Y-c
    ans = 2*C*c +min(A*x+B*y, 2*C*x+2*C*x)
print(ans)

Submission status: Wrong Answer

Solution code:
a,b,c,x,y = map(int,input().split())
d = a*x + b*y
e = 0
f = 0
g = 0
h = 0
if x > y and y % 2 == 0:
    e = c*2*y + a*(x-y)
elif x > y and y % 2 != 0:
    f = c*2*(y-1) + b + a*(x-y+1)
elif x < y and x % 2 == 0:
    g = c*2*x + b*(y-x)
elif x < y and x % 2 != 0:
    h = c*2*(x-1) + a + b*(y-x+1)
l = [d,e,f,g,h]
print(sorted(l)[3])

Submission status: Wrong Answer

Solution code:
a,b,c,x,y = map(int,input().split())
d = a*x + b*y
e = 0
f = 0
g = 0
h = 0
if x > y and y % 2 == 0:
    e = c*2*y + a*(x-y)
elif x > y and y % 2 != 0:
    f = c*2*(y-1) + b + a*(x-y+1)
elif x < y and x % 2 == 0:
    g = c*2*x + b*(y-x)
elif x < y and x % 2 != 0:
    h = c*2*(x-1) + a + b*(y-x+1)
l = [d,e,f,g,h]
print(sorted(l)[3])
print(l)

Submission status: Wrong Answer

Solution code:
A,B,C,X,Y = [int(x) for x in input().split()]
ans = 10**8
ans = min(ans,X*A+Y*B)
if(X<Y):
    ans = min(ans,2*X*C+(Y-X)*B)
else:
    ans = min(ans,2*Y*C+(X-Y)*A)
ans = min(ans,2*max(X,Y)*C)
print(ans)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

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

print(min(ans))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

while X > 0 or Y > 0:
    if X > 0 and Y > 0:
        if A + B > 2 * C:
            sum += 2 * C
            X -= 1
            Y -= 1
        else:
            sum += A + B
            X -= 1
            Y -= 1
    if X > 0 and Y > 0:
        continue
    if X > 0:
        if A > 2 * C:
            sum += 2 * C
            X -= 1
            Y -= 1
        else:
            sum += A
            X -= 1
    else:
        if B > 2 * C:
            sum += 2 * C
            X -= 1
            Y -= 1
        else:
            sum += B
            Y -= 1

print(sum)

Submission status: Wrong Answer

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

while X > 0 or Y > 0:
    if A + B > C:
        sum += C
        X -= 1
        Y -= 1
    else:
        sum += A + B
        X -= 1
        Y -= 1
    if X > 0 and Y > 0:
        continue
    if X > 0:
        if A > C:
            sum += C
            X -= 1
            Y -= 1
        else:
            sum += A
            X -= 1
    else:
        if B > C:
            sum += C
            X -= 1
            Y -= 1
        else:
            sum += B
            Y -= 1

print(sum)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
def f():
    if (A+B) <= C*2:
        return A*X+B*Y
    elif X==Y:
        return X*C*2
    else:
        if X > Y:
            if A > C*2:
                return (C*2)*(X-Y)+Y*C*2
            return A*(X-Y)+Y*C*2
        else:#Yの方が多い
            if B > C*2:
                return (C*2)*(Y-X)+X*C*2
            return B*(X-Y)+Y*C*2
A,B,C,X,Y = map(int,input().split())
print(f())

Submission status: Wrong Answer

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

print(ans)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!

A, B, AB, num_A, num_B = map(int, input().rstrip().split(' '))

min_cost = A * num_A + B * num_B
min_cost = min(min_cost, AB * 2 * max(num_A, num_B))
if num_A == num_B:
    min_cost = min(min_cost, AB * (num_A + num_B))
elif num_A > num_B:
    min_cost = min(min_cost, A * (num_A - num_B) + AB * 2 * num_B)
elif num_A > num_B:
    min_cost = min(min_cost, A * (num_B - num_A) + AB * 2 * num_A)
    
print(min_cost)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
a, b, c, x, y = [int(i) for i in input().split()]
min_a = a * x
min_b = b * y
min_c = max(x, y) * 2 * c
min_d = min(x, y) * 2 * c
min_a_b = min_a + min_b
if x > y:
    min_d = min_d + a * (x-y)
if x < y:
    min_d = min_d + a * (y-x)
if x != y:
    ans = min(min(min_a_b, min_c), min_d)
if x == y:
    ans = min(min_a_b, min_c)
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

def f(x,y):
    return x-y if x>y else 0

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

print(ans)

Submission status: Wrong Answer

Solution code:
A,B,C,X,Y=map(int,input().split())
#AB 
M=max(2*X,2*Y)
ans=10**9
for i in range(0,M+2,2):
    temp=i*2*C+max(0,X-i)*A+max(0,Y-i)*B
    ans=min(ans,temp)
print(ans)

Submission status: Wrong Answer

Solution code:
A,B,C,X,Y=map(int,input().split())
#AB 
M=max(2*X,2*Y)
ans=10**8
for i in range(0,M+2,2):
    temp=i*2*C+max(0,X-i)*A+max(0,Y-i)*B
    ans=min(ans,temp)
print(ans)

Submission status: Wrong Answer

Solution code:
def solve(string):
    a, b, c, x, y = map(int, string.split())
    if a + b <= 2 * c:
        return str(a * x + b * y)
    if 2 * c <= a and 2 * c <= b:
        return str(2 * c * max(x, y))
    base = 2 * c * min(x, y)
    diff = abs(x - y)
    return str(base + a * diff if x >= y else base + b * diff)


if __name__ == '__main__':
    print(solve(input()))