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: Runtime Error

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
    
  elif a+b <= c*2:
    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: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
ABpizza = C*2
cost = 0
if ABpizza <= A+B:
    tmp = min(X,Y)
    cost = cost + ABpizza * tmp
    X = X - tmp
    Y = Y - tmp

    if (cost + X*A + Y*B) >= (cost + (max(X,Y)*ABpizza)):
        cost = cost + ((max(X,Y)*ABpizza))
    else:
        cost = (cost + X*A + Y*B)
else:
    cost = (A*X) + (B*Y)

print(cost)

Submission status: Runtime Error

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

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

print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
Not found

Submission status: Runtime Error

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


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: Runtime Error

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 :
        if A < 2 * C:
            ans2 = Y * C * 2 + abs(X-Y) * A           
    else:
        if B < 2 * C:
            ans2 = X * C * 2 + abs(X-Y) * B  
    print(min(ans1,ans2)) #print()が分岐する
else:   
    ans = X * A + Y * B 
    print(ans)

Submission status: Runtime Error

Solution code:
1500 2000 1600 3 2

Submission status: Runtime Error

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

if (a+b)//2 <= c　and x != 0 and y != 0:
    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: Runtime Error

Solution code:
import math
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 = math.inf
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: Runtime Error

Solution code:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main()
{
  int a, b, c, x, y;
  cin >> a >> b >> c >> x >> y;
  int upp = 2*max(x, y);
  ll ans = 1000000000;
  int i=0;
  while(i <= upp)
  {
    ll price = max(x-i/2, 0)*a + max(y-i/2, 0)*b + c*i;
    ans = min(ans, price);
    i+=2;
  }
  cout << ans << endl;
  
}

Submission status: Runtime Error

Solution code:
cost_a,cost_b,cost_ab,num_a,num_b = map(int,input().split())
if num_a > num_b:
  num_ab = num_b * 2
  need_a = num_a - (num_ab // 2)
  if need_a < 0:
    need_a = -need_a
  cost1 = need_a * cost_a + num_ab * cost_ab
  
  num_ab = num_a * 2
  cost3 = num_ab * cost_ab
  
elif num_a < num_b:
  num_ab = num_a * 2
  need_b = num_b - (num_ab // 2)
  if need_b < 0:
    need_b = -need_b
  cost1 = need_b * cost_b + num_ab * cost_ab

  num_ab = num_b * 2
  cost3 = num_ab * cost_ab
else:
  num_ab = num_b * 2  
  cost1 = num_ab * cost_ab

cost2 = cost_a * num_a + cost_b * num_b
ans = min(cost1,cost2,cost3)
print(ans)

Submission status: Runtime Error

Solution code:
cost_a,cost_b,cost_ab,num_a,num_b = map(int,input().split())
if num_a > num_b:
  num_ab = num_b * 2
  need_a = num_a - (num_ab // 2)
  if need_a < 0:
    need_a = -need_a
  cost1 = need_a * cost_a + num_ab * cost_ab
  
  num_ab = num_a * 2
  need_b = num_b - (num_ab // 2)
  cost3 = need_b * cost_b + num_ab * cost_ab
  
elif num_a < num_b:
  num_ab = num_a * 2
  need_b = num_b - (num_ab // 2)
  if need_b < 0:
    need_b = -need_b
  cost1 = need_b * cost_b + num_ab * cost_ab

  num_ab = num_b * 2
  need_a = num_b - (num_ab // 2)
  cost3 = need_a * cost_a + num_ab * cost_ab
else:
  num_ab = num_b * 2  
  cost1 = num_ab * cost_ab
cost2 = cost_a * num_a + cost_b * num_b
ans = min(cost1,cost2,cost3)
print(ans)

Submission status: Runtime Error

Solution code:
import sys
import itertools
import math
from collections import deque
MAX_INT = int(10e15)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

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

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

Submission status: Runtime Error

Solution code:
A,B,AB,X,Y= int(input.split())
ans = (X * A) + (Y * B)
max_ab_cnt = max(X,Y)
for ab_cnt in (max_ab_cnt+1):
    a_cnt = max(X - ab_cnt, 0)
    b_cnt = max(Y - ab_cnt,0)
    tmp = (a_cnt *A) + (ab_cnt * 2 * AB) + (b_cnt * B)
    ans = min(ans, tmp)
print(ans)

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

a,b,c,x0,y0=mii()

tmp=10**10

if a+b >=2*c and x>=2 and y>=2:
    x,y=x0,y0
    chk=min(x//2,y//2)
    ans = c*2 *(x//2)*2
    x-=chk *2
    y-=chk*2 
    if x==1:
        ans+=a
    if y==1:
        ans+=b
    tmp=min(ans,tmp)
elif a+b <2*c:
    x,y=x0,y0
    ans =a*x+b*y

    tmp=min(ans,tmp)

x,y=x0,y0
ans=0
ans=a*x + c*2*y
tmp=min(ans,tmp)
ans=c*2*x+b*y
tmp=min(ans,tmp)



print(tmp)

Submission status: Runtime Error

Solution code:
a, b, c, x, y = map(int, input().split())
big = max(a, b)
small = min(a, b)
small_many = False
if (small == a and y <= x) or (small == b and x <= y):
    small_many = True
if big <= c:
    print(x * a + y * b)
elif small <= c < big:
    if ((big + small) <= 2 * c):
        print(x * a + y * b)
    else:
        if small_many:
            print(2 * c * min(x, y) + small * (max(x, y) - (min(x, y))))
        else:
            print(2 * c * max(x, y))
else:
    if small_many:
        print(2 * c * min(x, y) + small * (max(x, y) - (min(x, y))))
    else:
        print(min(2 * c * max(x, y)))

Submission status: Runtime Error

Solution code:
    else:

Submission status: Runtime Error

Solution code:
ans = max(A, B) * (X + Y)
for i in range(2 * 10 ** 5 + 100):
    c = i // 2
    x = i * C + max(X - c, 0) * A + max(Y - c, 0) * B
    ans = min(ans, x)

print(ans)

Submission status: Runtime Error

Solution code:
a,b,c,x,y=[int(s) for s in input().split()]
if x<=y:
  A=a
  B=b
  C=c
  X=x
  Y=y
else:
  A=b
  B=a
  C=c
  X=y
  Y=x
print(min[Y*2*C,X*2*C+(Y-X)*B,X*A+(Y-X)*B])

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
(a, b, c, wanted_a, wanted_b) = (int(tok) for tok in input().split())

res = wanted_a * a + wanted_b * b
for both in range(max(wanted_a, wanted_b) * 2):
  left_a = wanted_a - both // 2
  left_b = wanteD_b - both // 2
  cost = both * c + max(0, left_a) * a + max(0, left_b) * b
  res = min(res, cost)

print(res)

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>

using namespace std;

#define int long long 
#define INF 21000000000

signed main(){
		int a,b,c,n,m;
		cin >> a >> b >> c >> n >> m;
		int ans;
		if(a + b > m * 2){
				if(n > m) ans = c * m * 2 + a * (n - m);
				else ans = c * n * 2 + b * (m - n);
		}else{
				ans = a * n + b * m;
		}
		cout << ans << endl;
}

Submission status: Runtime Error

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

Submission status: Runtime Error

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: Runtime Error

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: Runtime Error

Solution code:
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: Runtime Error

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

print (ans)

Submission status: Runtime Error

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

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

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

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

Submission status: Runtime Error

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(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: Runtime Error

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

Submission status: Runtime Error

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)
elif a>=2*c:
  print(2*c*x+b*max(y-x,0))
elif b>=2*c:
  prinr(2*c*y+a*max(x-y,0))

Submission status: Runtime Error

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

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: Runtime Error

Solution code:
A,B,C,X,Y=(int(i) for i in input().split())
 
if A+B<2*C:
  print(A*X+B*Y)
  
elif min(X,Y)<=2*C:
  if X>Y:
    print((X-Y)*A+2*Y*C)
  else:
    print((Y-X)*B+2*X*C)
elif A<=B:
  if X>Y:
    print(2*C*Y+(X-Y)*A)
  else:
    orint(2*C*Y)
else:
  if X<Y:
    print(2*C*X+(Y-X)*B)
  else:
    print(2*C*X)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python
# coding: utf-8
"""
purpose
"""


def main() -> None:
    """
    main function
    """
    (A, B, C, X, Y) = map(int, input().strip().split())

    if 2 * C <= B and 2 * C <= A:
        ans = (max(X, Y) * 2) * C
    elif 2 * C > A:
        ans = Y * 2 * C + max(X - Y, 0) * B
    elif 2 * C > B:
        ans = X * 2 * C + max(Y - X, 0) * A
    else:
        raise ValueError(f"{A}, {B}, {C}")

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python
# coding: utf-8
"""
purpose
"""


def main() -> None:
    """
    main function
    """
    (A, B, C, X, Y) = map(int, input().trim().split())

    if 2 * C <= B and 2 * C <= A:
        ans = (max(X, Y) * 2) * C
    elif 2 * C > A:
        ans = Y * 2 * C + max(X - Y, 0) * B
    elif 2 * C > B:
        ans = X * 2 * C + max(Y - X, 0) * A
    else:
        raise ValueError(f"{A}, {B}, {C}")

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
C *= 2
ans = 0

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

print(ans)

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
for i in range(100000):
    price_new = i*2*c + max(0, x-i)*a + max(0, y-i)*b
    if i==0:
        price = price_new
    else:
        price = min(price, price_new)

print(price)

Submission status: Runtime Error

Solution code:
import numpy as np

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

DP = np.zeros(((X+1), (Y+1)), dtype=int)

DP[0][0] = 0

def dp(x, y):
    if x < 0 and y < 0:
        return DP[0][y]
    elif x < 0:
        return DP[0][y]
    elif y < 0:
        return DP[x][0]
    else:
        return DP[x][y]

    
for s in range(1, (X + Y + 2)):
    for y in range(0, s+1):
        x = s - y
        if 0 > x or x >= (X+1) or \
           0 > y or y >= (Y+1):
            continue
        pA = dp(x-1, y) + A
        pB = dp(x, y-1) + B
        pC = dp(x-1, y-1) + 2 * C
        if x - 1 < 0:
            pA = 1000000000
        if y - 1 < 0:
            pB = 1000000000
        if x - 1 < 0 and y - 1 < 0:
            pC = 1000000000
        # print('x, y', x, y)
        DP[x][y] = min(min(pA, pB), pC)
        # print('pA, pB, pC = ', pA, pB, pC)
        # print('DP[x][y] = ', DP[x][y])

# print(DP)

# for x in range(X):
#     for y in range(Y):
#         print(x, y, ": ", DP[x][y])
print(DP[X][Y])

Submission status: Runtime Error

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

# A 1枚、B 1枚を2C円で買うと捉え直す。
# ピザは、最大でも10**5枚（A, Bそれぞれに対して）
# A, Bのセットを、1~10**セットまで動かして一番安い組を考える

cheapest = float("inf")

for i in range(max(X, Y) + 1):

    price = 2 * C * i + A * max(0, X - i) + B * max(Y - i)

    cheapest = min(cheapest, price)

print(cheapest)

Submission status: Runtime Error

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

price = min(A*X+B*Y, C*2*max(x, y))

is_break = 0
for a in range(X+1):
    if is_break:
        break
    for b in range(Y+1):
        if is_break:
            break
        for c in range(2 * max((X-a), (Y-b)), 2 * max(X-a, Y-b) + 1):
            if price >= A*a+B*b+C*c:
                price = A*a+B*b+C*c
                is_break = 1
                break

print(price)

Submission status: Runtime Error

Solution code:
A,B,C,X,Y = (int(i) for i in input().split())
i = 0
a = []
while i <= 100000:
    p = i * 2*C + A*max(0,X-i)+B*max(0,Y-i)
    a.append(p)
    i += 1
print(min(a)

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

mincost = 10000000000

for a in range(X + 1):
    for b in range(Y + 1):
        c = max[(X - a) * 2, (Y - b) * 2]
        cost = a * A + b * B + c * C
        if (cost < mincost):
            mincost = cost

print(mincost)

Submission status: Runtime Error

Solution code:
l = list(input().split())
c = 0
for i in l:
 l[c] = int(l)
 c += 1

k = min(l[3],l[4])
money = min((l[0]+l[1])*k, l[2]*2*k)

if l[3]>l[4]:
 m = l[3]-l[4]
 money += min(l[0], l[2]*2)*m
else:
 m = l[4]-l[3]
 money += min(l[1], l[2]*2)*m

print(money)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
a_yen , b_yen, c_yen , a_count,b_count = map(int,input().split())

abmax = max(a_count, b_count)
c_count = 0
kouhopiza = a_yen * a_count + b_yen * b_count + c_yen * c_count

while c <= 2*abmax:
    if kouhopiza > a_yen * a_count + b_yen * b_count + c_yen * c_count and a_count > -1 and b_count > -1:
        kouhopiza = a_yen * a_count + b_yen * b_count + c_yen * c_count
    c_count = c_count + 2
    a_count = a_count - 1
    b_count = b_count - 1

Submission status: Runtime Error

Solution code:
a_yen , b_yen, c_yen , a_count,b_count = map(int,input().split())

abmax = max(a_count, b_count)
c_count = 0
kouhopiza = a_yen * a_count + b_yen * b_count + c_yen * c_count

while c <= 2*abmax:
    if kouhopiza > a_yen * a_count + b_yen * b_count + c_yen * c_count and a_counnt > -1 and b_count > -1:
        kouhopiza = a_yen * a_count + b_yen * b_count + c_yen * c_count
    c_count = c_count + 2
    a_count = a_count - 1
    b_count = b_count - 1

Submission status: Runtime Error

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


price = a*A + b*B + c*C
print(price)

Submission status: Runtime Error

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

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

val_s = (A*X) + (B*Y)

if val > val_s:
  ans = val_s
else:
  ans = val

print(ans)

Submission status: Runtime Error

Solution code:
total_price=0
C2=C*2

if C2<=A and C2<=B:
    total_price=C2*max(X,Y)
        
elif (C2>=A and C2<=B):
    total_price=C2*min(X,Y)
    total_price=total_price+B*(Y-X)      
    print(total_price)
    
elif (C2<=A and C2>=B) :
    total_price=C2*min(X,Y)
    total_price=total_price+A*(X-Y)      
    print(total_price)

elif C2<=(A+B):  #C2<=(A+B): 
    if X>=Y:
        total_price=C2*Y
        X=X-Y
        Y=0
        total_price=total_price+A*X
    else:
        total_price=C2*X
        X=0
        Y=Y-X
        total_price=total_price+B*Y
        
else:
    total_price=A*X+B*Y
print(total_price)

Submission status: Runtime Error

Solution code:
total_price=0
C2=C*2

if C2<=A and C2<=B:
    total_price=C2*max(X,Y)

elif C2<=(A+B):
    if X>=Y:
        total_price=C2*Y
        X=X-Y
        Y=0
        total_price=total_price+A*X
    else:
        total_price=C2*X
        X=0
        Y=Y-X
        total_price=total_price+B*Y
        
else:
    total_price=A*X+B*Y
print(total_price)

Submission status: Runtime Error

Solution code:
def C(A,B,C,X,Y):
    both_price=min(A+B,C*2)
    A_price=min(A,C*2)
    B_price=min(B,C*2)
 
    both_num=min(X,Y)
    X_num=X-both_num
    Y_num=Y-both_num
    return both_price*both_num+X_num*A_price+Y_num*B_price
 
inp = sys.stdin.read().split()
inp=[int(i) for i in inp]
print(C(inp[0], inp[1], inp[2],inp[3],inp[4],inp[5]))

Submission status: Runtime Error

Solution code:
l = input().split()
A = int(l[0])
B = int(l[1])
AB = int(l[2])
a = int(l[3])
b = int(l[4])

sum = 0

if A+B < AB*2:
    if a < b:
        sum += a*AB
        sum += b*B
    else:
        sum += b*AB
        sum += a*A
else:
    sum += a*A + b*B

print sum

Submission status: Runtime Error

Solution code:
a = input()
l = map(int, raw_input().split())
t=[]
for i in range(a):
    m = del l[i]
    m.sort()
    answer = m[a/2]
    t.append(answer)

for i in range(a):
    print(t[i] "\n")

Submission status: Runtime Error

Solution code:
l = list(map(int,input().split()))
A = l[0]
B = l[1]
C = l[2]
X = l[3]
Y = l[4]
Z = 0
total = 0
a = []

for i in range(X+1):
	p = X-i
	for j in range(Y+1):
		q = Y-j
		total = p*A + q*B + max(i,j)*2*C
		a.append(total)

print(min(total))

Submission status: Runtime Error

Solution code:

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

def dp(num_a,num_b):
    if num_a<=0 and num_b<=0:return 0
    elif num_b!=0:
        if B<2*C:return B+dp(num_a,num_b-1)
        else :return C*2+dp(num_a-1,num_b-1)
    else:
        if A<2*C:return A+dp(num_a-1,num_b)
        else: return C*2+dp(num_a-1,num_b-1)
print(dp(X,Y))

Submission status: Runtime Error

Solution code:

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

def dp(num_a,num_b,num_ab_a,num_ab_b):
    if num_a<=0 and num_b<=0:return 0
    elif num_b!=0:
        return min(B+dp(num_a,num_b-1,num_ab_a,num_ab_b),C*2+dp(num_a-1,num_b-1,num_ab_a,num_ab_b))
    else:
        return min(A+dp(num_a-1,num_b,num_ab_a,num_ab_b),C*2+dp(num_a-1,num_b-1,num_ab_a,num_ab_b))
print(dp(X,Y,0,0))

Submission status: Runtime Error

Solution code:
a,b,c,x,y = map(int,input().split())
fx = x
fy = y
fl = 0
val = int(0)
fmin = min(x,y)
if a>2*c:
  val += 2*c*x
  y = y - x
  x = 0
  fl += 1
if y<0:
  y=0
if b>2*c:
  if fl == 1:
    val += 2*c*y
    y = 0
  else:
    val += 2*c*y
    x = x - y
    y = 0 
if x<0:
  nx = 0
else:
  nx = x
if y<0:
  ny = 0
else:
  ny = y
if a+b>2*c:
  nnx = nx - min(nx,ny)
  nny = ny - min(nx,ny)
  val += 2*c*min(nx,ny)
print(val+a*nnx+b*nny)

Submission status: Runtime Error

Solution code:
a = input().split()
money = 0
pizza = int(a[3])
pizzb = int(a[4])

if int(a[2])>int(a[0]) or int(a[2])>int(a[1]):
  
  if pizza<pizzb:
    while pizza<pizzb:
      money += int(a[1])
      pizzb -= 1
  elif pizza > pizzb:
    while pizza > pizzb:
      money += int(a[0])
      pizza -= 1

  if int(a[0])+int(a[1]) < int(a[2])*2:
    while pizza > 0:
      money += int(a[0])
      money += int(a[1])
      pizza -= 1
  elif int(a[0])+int(a[1]) > int(a[2])*2:
    while pizza > 0:
      money += int(a[2])*2
      pizza -= 1
      
else:
  m = max(pizza, pizzb)
  money = m*2*int(a[2])
  
print(money+"\n")

Submission status: Runtime Error

Solution code:
a = input().split()
s = 0
slist = []
num = 0
 
for i in range(int(a[0])):
  slist.append(input())
  s = s+int(slist[i])
  num += 1
  
if s == int(a[1]):
  print(num)
else:
  s = int(a[1])-s
  temp = s % int(min(slist))
  num = num + ((s-temp)/int(min(slist)))
  print(int(num)+"\n")

Submission status: Runtime Error

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

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

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

print(res)

Submission status: Runtime Error

Solution code:
A, B, C, X, Y = map(int, input().split())
pizza = [A, B, C]
count = [X, Y]
price = 0
if pizza[0]+pizza[1] >= 2 * pizza[2]:
	tmp = min(count)
	price += 2 * tmp * pizza[tmp]
	count[count.index(tmp)] = 0
	count[count.index(max(count))] -= tmp

for i in count:
	price += pizza[count.index(i)] * i

print(price)

Submission status: Runtime Error

Solution code:
A, B, C, X, Y = map(int, input().split())
pizza = [A, B, C]
count = [X, Y]
price = 0
print(pizza, count, price)
if pizza[0]+pizza[1] >= 2 * pizza[2]:
	tmp = min(count)
	price += 2 * tmp * pizza[tmp]
	count[count.index(tmp)] = 0
	count[count.index(max(count))] -= tmp

for i in count:
	price += pizza[count.index(i)] * i

print(price)