input
stringlengths
20
127k
target
stringlengths
20
119k
problem_id
stringlengths
6
6
print((eval(input().replace(' ','*'))))
print((eval(input().replace(*' *'))))
p02657
print((eval(input().replace(' ','*'))))
def solve(): print((eval(input().replace(' ', '*')))) if __name__ == '__main__': solve()
p02657
#169 #値 A×Bを整数として出力せよ #入力 a, b = list(map(int, input().split())) #print(a,b) #処理 answer=a*b #結果 print(answer)
A, B = list(map(int, input().split())) print((A*B))
p02657
# 169A # A * Bを整数として出力 # 1.入力をプログラムで扱えるように受け取る a, b = list(map(int, input().split())) # print(a, b) # 2.受け取った入力値を使って、適切に処理(計算)すること answer = a * b # 3.計算した結果を出力すること print(answer)
# 入力をプログラムで扱えるようにする a, b = list(map(int, input().split())) # 受け取った値使って計算      answer = a * b # 結果の出力 print(answer)
p02657
a, b = (int(x) for x in input().split()) print((a * b))
a, b = list(map(int, input().split())) print((a*b))
p02657
# 169A #1.入力をちゃんと受け取ること #ex:「2 5」⇒ a = 2, b = 5 みたいにしないといけない。 a, b = list(map(int, input().split())) #print(a) #print(b) #2.目的通りの計算をする #ex:2つの整数AとBの掛け算をやる answer = a * b #3.計算の結果を出力する print(answer)
a, b = list(map(int, input().split())) answer = a * b print(answer)
p02657
A, B = list(map(int, input().split())) print((A*B))
print((eval(input().replace(' ','*'))))
p02657
A, B = list(map(int, input().split())) print((A*B))
a, b = list(map(int, input().split())) print((a*b))
p02657
a, b = list(map(int, input().split())) answer = a * b print(answer)
# 入力(スペースで区切って入力) a,b = list(map(int,input().split())) # 掛け算をする print(( a * b ))
p02657
from sys import stdin A, B = list(map(float,input().split())) result = int(A * B) print(result)
A, B = list(map(float,input().split())) result = int(A * B) print(result)
p02657
A, B = list(map(float,input().split())) result = int(A * B) print(result)
x, y = list(map(int, input().split())) result = x * y print(result)
p02657
# coding: utf-8 A, B, C, X, Y = list(map(int, input().split())) pt1 =(A*X)+(B*Y) pt2 = 2*C*max(X,Y) pt3 = 2*C*min(X,Y)+((A*(X-Y)) if X>Y else B*(Y-X)) print((min(pt1,pt2,pt3)))
# coding: utf-8 A, B, C, X, Y = list(map(int, input().split())) print((min((A*X)+(B*Y),2*C*max(X,Y),2*C*min(X,Y)+((A*(X-Y)) if X>Y else B*(Y-X)))))
p03371
a,b,c,x,y = list(map(int,input().split())) price = 10**10 for k in range(10**5+1): re = 2*c*k + max(0,x-k)*a + max(0,y-k)*b price = min(re,price) print(price)
a,b,c,x,y = list(map(int,input().split())) a1 = a*x + b*y a2 = max(x,y) * 2*c if y >= x: a3 = 2*c*x + (y-x)*b else: a3 = 2*c*y + (x-y)*a print((min(a1,a2,a3)))
p03371
# -*- coding: utf-8 -*- A, B, C, X, Y = list(map(int, input().split())) cost = int(1e10) for num_ac in range(0, int(1e5) + 1): num_A = max(0, X - num_ac) num_B = max(0, Y - num_ac) c = 2 * C * num_ac + A * num_A + B * num_B cost = min(c, cost) print(cost)
A, B, C, X, Y = list(map(int, input().split())) ans = 0 if A + B > 2 * C: z = min(X, Y) X -= z Y -= z ans += 2 * z * C # 偏り分 if 2 * C < A: k = X X -= k Y -= k ans += 2 * C * k if 2 * C < B: k = Y X -= k Y -= k ans += 2 * C * k # あまり分 ans += A * max(0, X) + B * max(0, Y) print(ans)
p03371
a, b, c, x, y = list(map(int, input().split())) ans = float('inf') for i in range(2 * 10**5 + 1): ans = min(ans, a * max(x - i, 0) + b * max(y - i, 0) + 2 * c * i) print(ans)
A,B,C,X,Y = list(map(int,input().split())) min_xy = min(X,Y) max_xy = max(X,Y) ans1 = 2 * C * min_xy + A * (X-min_xy) + B * (Y-min_xy) # 無駄にならない範囲でABピザを買い、残りを買う ans2 = A*X + B*Y # ABピザを買わない ans3 = 2 * C * max_xy # ABピザだけを買う print((min(ans1,ans2,ans3)))
p03371
import sys def input(): return sys.stdin.readline().strip() def resolve(): import math a,b,c,x,y=list(map(int, input().split())) cmax=max(x,y)*2 l=[] for i in range(cmax+1): amai = max(math.ceil(x - 0.5 * i),0) bmai = max(math.ceil(y - 0.5 * i),0) l.append(amai*a+bmai*b+i*c) print((min(l))) resolve()
import sys def input(): return sys.stdin.readline().strip() def resolve(): import math a,b,c,x,y=list(map(int, input().split())) # ABピザを奇数枚買っても1枚無駄になるから、ABピザは2枚を1枚だと考える # cの値段を2倍にして枚数を半分に cmax=max(x,y) # ABピザの最大枚数(2枚を1枚と考えたとき) c=2*c l=[] for i in range(cmax+1): amai = max(x - i,0) bmai = max(y - i,0) l.append(amai*a+bmai*b+i*c) print((min(l))) resolve()
p03371
a, b, c, x, y = list(map(int, input().split())) mi = 10**10 for i in range(10**6): cost = c*2*i + a*max((x-i), 0) + b*max((y-i), 0) if cost < mi: mi = cost print(mi)
a, b, c, x, y = list(map(int, input().split())) if x > y: cost = min(a*x + b*y, x*c*2, y*c*2 + (x-y)*a) else: cost = min(a*x + b*y, y*c*2, x*c*2 + (y-x)*b) print(cost)
p03371
A,B,C,X,Y=list(map(int,input().split())) #AB M=max(2*X,2*Y) ans=10**9 for i in range(0,M+2,2): temp=i*C+max(0,X-(i//2))*A+max(0,Y-(i//2))*B ans=min(ans,temp) print(ans)
import sys, re, os from collections import deque, defaultdict, Counter from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians from itertools import permutations, combinations, product, accumulate from operator import itemgetter, mul from copy import deepcopy from string import ascii_lowercase, ascii_uppercase, digits from heapq import heapify, heappop, heappush def input(): return sys.stdin.readline().strip() def INT(): return int(eval(input())) def MAP(): return list(map(int, input().split())) def S_MAP(): return list(map(str, input().split())) def LIST(): return list(map(int, input().split())) def S_LIST(): return list(map(str, input().split())) sys.setrecursionlimit(10 ** 9) INF = float('inf') mod = 10 ** 9 + 7 A, B, C, X, Y = MAP() ans = INF ma = max(X, Y) t = ma * C * 2 ans = A * X + B * Y # print(ans, t) # exit() mi = min(X, Y) mi_X = X - mi mi_Y = Y - mi tmp = mi_X * A + mi_Y * B + C * mi * 2 ans = min(ans, tmp, t) print(ans) exit() # for i in range(): # print(ans) for i in range(min(X, Y) + 1): tmp = A * (X - i) + B * (Y - i) + C * 2 * i print(tmp) ans = min(tmp, ans) print(ans) # i = 0 # new = 0 # while new < ans: # new = A * (X - i) + B * (Y - i) + C * 2 * i # ans = min(ans, new) # print(ans) # i += 1 # print(ans) # if new < ans: # ans = new # i += 1 # else: # print(ans) # break
p03371
def cmd(): A, B, C, X, Y = list(map(int, input().split())) buyAB = A*X + B*Y if X == Y: buyminC = C*2*min(X,Y) elif X > Y: buyminC = C*2*min(X,Y) + A*(X-Y) else: buyminC = C*2*min(X,Y) + B*(Y-X) buymaxC = C*2*max(X,Y) #print("buyAB:{}, buyminC:{}, buymaxC:{}".format(buyAB, buyminC, buymaxC)) print((min(buyAB, buyminC, buymaxC))) if __name__ == "__main__": cmd()
def main(): A, B, C, X, Y = list(map(int, input().split())) M1 = A*X + B*Y M2 = C*2*min(X, Y) + (Y >= X) * (Y - X) * B + (X > Y) * (X - Y) * A M3 = C*2*max(X, Y) ans = min(M1, M2, M3) print(ans) if __name__ == "__main__": main()
p03371
# AtCoder Beginner Contest 095 C - Half and Half import sys A, B, C, X, Y = list(map(int, sys.stdin.readline().strip().split())) ans = A * X + B * Y for z in range(2, 2 * 10 ** 5 + 1, 2): x = max(X - int(z / 2), 0) y = max(Y - int(z / 2), 0) price = A * x + B * y + C * z ans = min(price, ans) print(ans)
# AtCoder Beginner Contest 095 C - Half and Half import sys A, B, C, X, Y = list(map(int, sys.stdin.readline().strip().split())) """ ans = A * X + B * Y for z in range(2, 2 * 10 ** 5 + 1, 2): x = max(X - int(z / 2), 0) y = max(Y - int(z / 2), 0) price = A * x + B * y + C * z ans = min(price, ans) print(ans) """ price1 = A * X + B * Y price2 = C * 2 * X + B * max(Y - X, 0) price3 = A * max(X - Y, 0) + C * 2 * Y print((min(price1, price2, price3)))
p03371
A, B, C, X, Y = list(map(int, input().split())) if A + B < 2 * C: print((A * X + B * Y)) else: # ABピザを二枚ずつ増やしていく。最大は2(max(x,y)) ans = float('inf') for i in range(0, max(X, Y) * 2 + 1, 2): ans = min(ans, max(A * (X - i // 2), 0) + max(B * (Y - i // 2), 0) + C * i) print(ans)
def solve(): A,B,C,X,Y = list(map(int, input().split())) ans = X*A + Y*B for i in range(max(X,Y)+1): aandb = A * max(0, X-i) + B * max(0, Y-i) ab = 2*C*i ans = min(ans, aandb + ab) print(ans) if __name__ == '__main__': solve()
p03371
# C - Half and Half A, B, C, X, Y = list(map(int, input().split())) # 条件を満たすときのA, B, ABの買い方を全列挙したい # A, Bの枚数は、ABの値が決まれば、一意に定まるため、 # ABのみループする。 ans = 10**18 for i in range(0, max(X, Y)*2+1, 2): x = max(X-i//2, 0) y = max(Y-i//2, 0) ans = min(ans, x*A + y*B + i*C) print(ans)
A, B, C, X, Y = list(map(int, input().split())) ans = 10**18 for i in range(0, 2*max(X, Y)+2, 2): ans = min(ans, i * C + max(X-(i//2), 0) * A + max(Y-(i//2), 0) * B) print(ans)
p03371
ans = 0 A, B, AB, X, Y = list(map(int, input().split())) AB = min(AB * 2, A + B) m = min(X, Y) ans += m * AB X -= m Y -= m if X == 0: ans += min(B, AB) * Y else: ans += min(A, AB) * X print(ans)
a, b, c, x, y = list(map(int, input().split())) if a + b <= c * 2: print((a * x + b * y)) else: if x <= y: print((c * min(x, y) * 2 + abs(x - y) * min(b, c * 2))) else: print((c * min(x, y) * 2 + abs(x - y) * min(a, c * 2)))
p03371
a, b, c, x, y = list(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 = a*x + b*y print(ans)
a, b, c, x, y = list(map(int, input().split())) def f(x,y): return x-y if x>y else 0 print((min(2*c*x + f(y,x)*b, 2*c*y + f(x,y)*a, a*x+b*y)))
p03371
A,B,C,X,Y = list(map(int,input().split())) l = [] for i in range(max(X,Y)+1): T = i * C * 2 if i < X: T += (X-i)*A if i < Y: T += (Y-i)*B l.append(T) l.sort() print((l[0]))
A,B,C,X,Y = list(map(int,input().split())) ans = 0 if 2*C <= A+B: Z = min(X,Y) ans = 2*C*Z X -= Z Y -= Z ans += min(2*C*X,A*X) ans += min(2*C*Y,B*Y) print(ans)
p03371
def check(): A, B, C, X, Y = [int(i) for i in input().split(' ')] if X > 0 and Y > 0: if 2*C < A+B: if X > Y: total = Y*2*C price = min(A, 2*C) total += (X-Y)*price else: total = X*2*C price = min(B, 2*C) total += (Y-X)*price else: total = A*X + B*Y elif X == 0: price = min(B, 2*C) total = price*Y else: price = min(A, 2*C) total = price*X print(total) check()
def solve(): A, B, C, X, Y = list(map(int, input().split())) x1 = min(X, Y) price = min((A+B) * x1, 2 * C * x1) x2 = max(X, Y) - x1 a = A if X > Y else B price += min(a * x2, 2 * C * x2) print(price) solve()
p03371
a, b, c, x, y = list(map(int, input().split())) ans = float('inf') for i in range(10**5 + 1): tmp = c*2*i + max(0, x-i) * a + max(0, y-i) * b ans = min(ans, tmp) print(ans)
a, b, c, x, y = list(map(int, input().split())) ans = float('inf') for i in range(max(x, y) + 1): tmp = c*2*i + max(0, x-i) * a + max(0, y-i) * b ans = min(ans, tmp) print(ans)
p03371
a, b, c, x, y = list(map(int,input().split())) price = a * x + b * y for i in range(max(x,y)+1): new_price = c * 2 * i + max(a * (x - i),0) + max(b * (y - i),0) price = min(price,new_price) print(price)
a, b, c, x, y = list(map(int,input().split())) price = a * x + b * y for i in range(max(x,y)+1): price = min(price,c * 2 * i + max(a * (x - i),0) + max(b * (y - i),0)) print(price)
p03371
A, B, C, X, Y = list(map(int, input().split())) """ ABピザの購入数(0~2 * max(X, Y)で全探索) """ min_price = 10 ** 10 for i in range(2 * max(X, Y) + 1): c_price = C * i a_price = A * max(0, (X - i//2)) b_price = B * max(0, (Y - i//2)) min_price = min(min_price, a_price+b_price+c_price) print(min_price)
a, b, c, x, y = list(map(int, input().split())) ans = 10 ** 18 for i in range(0, 2 * max(x, y) + 1, 2): tmp = i * c if x - i // 2 > 0: tmp += (x - i // 2) * a if y - i // 2 > 0: tmp += (y - i // 2) * b ans = min(ans, tmp) print(ans)
p03371
a,b,c,x,y=list(map(int,input().split())) ans=float('inf') for i in range(10**5+1): temp=i*2*c + max(0,x-i)*a +max(0,y-i)*b ans=min(ans,temp) print(ans)
a,b,c,x,y=list(map(int,input().split())) ans=float('inf') for i in range(10**5+1): tmp=i*c*2+a*max(x-i,0)+b*max(y-i,0) ans=min(ans,tmp) print(ans)
p03371
a,b,c,x,y=list(map(int,input().split())) ans=a*x+b*y for ci in range(max(x,y)+1): sumc = 2*ci*c sumc += (x-ci)*a if (x-ci)>0 else 0 sumc += (y-ci)*b if (y-ci)>0 else 0 ans=min(ans,sumc) print(ans)
a,b,c,x,y=list(map(int,input().split())) ans=a*x+b*y if x==y: 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)
p03371
# author: kagemeka # created: 2019-11-07 12:33:44(JST) import sys # import collections # import math # import string # import bisect # import re # import itertools # import statistics # import functools # import operator def main(): a, b, c, x, y = (int(i) for i in sys.stdin.readline().split()) if a + b <= c * 2: cost = a * x + b * y elif x >= y: atleast = y cost = c * atleast * 2 remainder = x - atleast if a <= c * 2: cost += a * remainder else: cost += c * remainder * 2 else: atleast = x cost = c * atleast * 2 remainder = y - atleast if b <= c * 2: cost += b * remainder else: cost += c * remainder * 2 print(cost) if __name__ == "__main__": # execute only if run as a script main()
import sys a, b, c, x, y = list(map(int, sys.stdin.readline().split())) if x < y: x, y = y, x a, b = b, a def main(): if a + b <= c * 2: cost = a * x + b * y else: cost = c * 2 * y if a <= c * 2: cost += a * (x - y) else: cost += c * 2 * (x - y) return cost if __name__ == '__main__': ans = main() print(ans)
p03371
import sys input = sys.stdin.readline sys.setrecursionlimit(10 ** 7) A, B, C, X, Y = list(map(int, input().split())) ans = 0 if X >= Y: ans = min(A*X+B*Y, C*(Y)*2+A*(X-Y)) else: ans = min(A*X+B*Y, C*(X)*2+B*(Y-X)) ans = min(ans, C*max(X, Y)*2) print(ans)
import sys stdin = sys.stdin sys.setrecursionlimit(10 ** 7) i_i = lambda: int(i_s()) i_l = lambda: list(map(int, stdin.readline().split())) i_s = lambda: stdin.readline().rstrip() A, B, C, X, Y = i_l() if X < Y: X * C + (Y - X) * B print((min((X * A + Y * B), (X * C * 2 + (Y - X) * B), C * max(X, Y) * 2))) else: print((min((X * A + Y * B), (Y * C * 2 + (X - Y) * A), C * max(X, Y) * 2)))
p03371
A,B,C,X,Y = list(map(int,input().split())) Ans = 0 Z = min(X,Y) if A+B < C*2: Ans = A*X+B*Y else: Ans = min(C*2*Z + A*(X-Z) + B*(Y-Z), C*2*max(X,Y)) print(Ans)
# Python3 (3.4.3) import sys input = sys.stdin.readline # ------------------------------------------------------------- # function # ------------------------------------------------------------- # ------------------------------------------------------------- # main # ------------------------------------------------------------- A,B,C,X,Y = list(map(int,input().split())) ans = 0 Z = min(X,Y) if A+B >= C*2: ans = min(C*Z*2 + A*(X-Z) + B*(Y-Z), C*max(X,Y)*2) else: ans = A*X + B*Y print(ans)
p03371
a,b,c,x,y = list(map(int,input().split())) res = 0 res += min(a+b,2*c)*min(x,y) if x >= y: res += min(2*c*(x-y),a*(x-y)) else: res += min(2*c*(y-x),b*(y-x)) print(res)
A,B,C,X,Y = list(map(int,input().split())) res = min(A+B,2*C)*min(X,Y) if X >= Y: res += min(A,2*C)*(X-Y) else: res += min(B,2*C)*(Y-X) print(res)
p03371
A, B, C, X, Y = list(map(int, input().split())) # xn, yn = 0, 0 # price = 0 # # if (A+B) >= 2*C and A >= 1 and B >= 1: # ammount = min(X, Y) # price += C * ammount * 2 # xn += ammount # yn += ammount # # if A >= 2*C and X > xn: # ammount = X - xn # price += C * X * 2 # xn += X # yn += X # # if B >= 2*C and Y > yn: # ammount = Y - yn # price += C * ammount * 2 # xn += ammount # yn += ammount # # price += A * (X - xn) # price += B * (Y - yn) # # print(price) # min_price = 1 << 32 for i in range(max(X, Y)+1): xn, yn = i, i price = (2*C) * i price += (max(0, X - xn)) * A price += (max(0, Y - yn)) * B min_price = min(min_price, price) print(min_price)
A, B, C, X, Y = list(map(int, input().split())) xn, yn = 0, 0 price = 0 if A >= 2*C and X > xn: ammount = X - xn price += C * X * 2 xn += X yn += X if B >= 2*C and Y > yn: ammount = Y - yn price += C * ammount * 2 xn += ammount yn += ammount if (A+B) >= 2*C and (X - xn) >= 1 and (Y - yn) >= 1: ammount = min(X, Y) price += C * ammount * 2 xn += ammount yn += ammount if X - xn >= 1: price += A * (X - xn) if Y - yn >= 1: price += B * (Y - yn) print(price) # min_price = 1 << 32 # for i in range(max(X, Y)+1): # xn, yn = i, i # price = (2*C) * i # price += (max(0, X - xn)) * A # price += (max(0, Y - yn)) * B # min_price = min(min_price, price) # # print(min_price)
p03371
# https://atcoder.jp/contests/abc095/tasks/arc096 # 値段,枚数 A, B, C, X, Y = list(map(int, input().split())) ans = float("inf") for i in range(10 ** 5 * 2): ans = min(ans, max(X - i, 0) * A + max(Y - i, 0) * B + 2 * i * C) print(ans)
a, b, c, x, y = list(map(int, input().split())) ans = float('inf') for i in range(10 ** 5 + 1): price = i * 2 * c if x > i: price += a * (x - i) if y > i: price += b * (y - i) ans = min(ans, price) print(ans)
p03371
a, b, c, x, y = list(map(int, input().split())) # print(a, b, c, x, y) ans = 10000 * (10 **5) + 7 c_max = 0 if x > y: c_max = x * 2 else: c_max = y * 2 for cc in range(c_max+1): ac = x - (cc // 2) bc = y - (cc // 2) if ac < 0: ac = 0 if bc < 0: bc = 0 price = ac * a + bc * b + cc * c # print('price: {}, ac: {}, bc: {}, cc: {}'.format(price, ac, bc, cc)) ans = min(ans, price) print(ans)
a, b, c, x, y = list(map(int, input().split())) # print(a, b, c, x, y) ans = 10000 * (10 **5) + 7 c_max = 0 if x > y: c_max = x * 2 else: c_max = y * 2 for cc in range(0, c_max+1, 2): ac = x - (cc // 2) bc = y - (cc // 2) if ac < 0: ac = 0 if bc < 0: bc = 0 price = ac * a + bc * b + cc * c # print('price: {}, ac: {}, bc: {}, cc: {}'.format(price, ac, bc, cc)) ans = min(ans, price) print(ans)
p03371
A, B, C, X, Y = list(map(int, input().split())) MAX = max(X, Y) MIN = 2*C*max(X, Y) i = MAX x=X y=Y while i > 0: tmpC = (MAX-i)*2*C total = (A*x)+(B*y)+tmpC if(MIN > total): MIN = total i-=1 if(x!=0): x-=1 if(y!=0): y-=1 print(MIN)
def myAnswer(A:int,B:int,C:int,X:int,Y:int) -> int: ans = 0 both = C * 2 AB=A+B while X!=0 or Y!=0: if(X>=1 and Y >=1): ans += min(AB,both) X-=1 Y-=1 elif(X>=1 and Y == 0): ans += min(both,A) X -= 1 else: ans += min(both,B) Y -= 1 return ans def modelAnswer(): tmp=1 def main(): A,B,C,X,Y=list(map(int,input().split())) print((myAnswer(A,B,C,X,Y))) if __name__ == '__main__': main()
p03371
def main(): A, B, C, X, Y = (int(i) for i in input().split()) ans1 = A * X + B * Y ans2 = 0 ans3 = 0 if X < Y: ans2 += 2 * C * X ans2 += B * (Y-X) ans3 += 2 * C * Y else: ans2 += 2 * C * Y ans2 += A * (X-Y) ans3 += 2 * C * X print((min(ans1,ans2,ans3))) if __name__ == '__main__': main()
def main(): a, b, c, x, y = (int(i) for i in input().split()) ans = 0 if x > y: p = (x - y)*a elif y > x: p = (y - x)*b else: p = 0 print((min(a*x + b*y, 2*c*max(x, y), 2*c*min(x, y) + p))) if __name__ == '__main__': main()
p03371
def main(): a, b, c, x, y = (int(i) for i in input().split()) ans = a*x + b*y ans = min(ans, 2*c*max(x, y)) if x < y: d = y - x d *= b else: d = x - y d *= a ans = min(ans, 2*c*min(x, y)+d) print(ans) if __name__ == '__main__': main()
def main(): a, b, c, x, y = (int(i) for i in input().split()) v1 = 2*c*max(x, y) v2 = 2*c*min(x, y) + (y-x if x < y else x-y)*(b if x < y else a) v3 = a*x + b*y print((min(v1, v2, v3))) if __name__ == '__main__': main()
p03371
A, B, C, X, Y = list(map(int, input().split())) ans = float('inf') for i in range(max(X,Y)+1): cost = 2 * C * i + max(0,X-i)*A +max(0,Y-i)*B ans = min(ans,cost) print(ans)
A, B, C, X, Y = list(map(int, input().split())) tmp = A*X + B*Y if X >= Y: tmp = min(tmp,2*Y*C+(X-Y)*A) else: tmp = min(tmp,2*X*C+(Y-X)*B) tmp = min(tmp,max(X,Y)*2*C) print(tmp)
p03371
#!/usr/bin/env python3 import sys, math, fractions, itertools def solve(A: int, B: int, C: int, X: int, Y: int): mn = 1e9 for i in range(0, 2*(max(X, Y)+1), 2): mn = min(mn, C*i+A*max(X-i//2, 0)+B*max(Y-i//2, 0)) print((int(mn))) return # Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools (tips: You use the default template now. You can remove this line by using your custom template) def main(): def iterate_tokens(): for line in sys.stdin: for word in line.split(): yield word tokens = iterate_tokens() A = int(next(tokens)) # type: int B = int(next(tokens)) # type: int C = int(next(tokens)) # type: int X = int(next(tokens)) # type: int Y = int(next(tokens)) # type: int solve(A, B, C, X, Y) if __name__ == '__main__': main()
#!/usr/bin/env python3 import sys def solve(A: int, B: int, C: int, X: int, Y: int): c = 0 if (A + B < 2 * C): c += min(X, Y) * (A + B) else: c += min(X, Y) * 2 * C if X > Y: c += (X - Y) * min(A, 2 * C) else: c += (Y - X) * min(B, 2 * C) print(c) return # Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools (tips: You use the default template now. You can remove this line by using your custom template) def main(): def iterate_tokens(): for line in sys.stdin: for word in line.split(): yield word tokens = iterate_tokens() A = int(next(tokens)) # type: int B = int(next(tokens)) # type: int C = int(next(tokens)) # type: int X = int(next(tokens)) # type: int Y = int(next(tokens)) # type: int solve(A, B, C, X, Y) if __name__ == '__main__': main()
p03371
a,b,c,x,y=list(map(int,input().split())) k=min(x,y) ans=0 if 2*c < a+b: ans+=2*c*k d=x-y if d>=0: ans+=min(a*d,2*c*d) else: ans+=min(b*(-d),2*c*(-d)) else: ans+=min(a*x,2*c*x)+min(b*y,2*c*y) print(ans)
a,b,c,x,y=list(map(int,input().split())) k=min(x,y) ans=0 AB = 2*c if 2*c < a+b: ans+=AB*k d=x-y if d>=0: ans+=min(a*d,AB*d) else: ans+=min(b*(-d),AB*(-d)) else: ans+=min(a*x,AB*x)+min(b*y,AB*y) print(ans)
p03371
A, B, C, X, Y = list(map(int, input().split())) ans = A * X + B * Y for i in range(100001): total = 2 * C * i + A * max(0, X - i) + B * max(0, Y - i) ans = min(ans, total) print(ans)
A, B, C, X, Y = list(map(int, input().split())) ans = A * X + B * Y for i in range(10 ** 5 + 1): total = 2 * C * i + A * max(0, X - i) + B * max(0, Y - i) ans = min(total, ans) print(ans)
p03371
a,b,c,x,y = list(map(int,input().split())) c *= 2 ans = 10 ** 16 for i in range(max(x,y) + 1): p = 0 p += c * i p += a * (max(0,x - i)) p += b * (max(0,y - i)) ans = min(ans,p) print(ans)
a,b,c,x,y = list(map(int,input().split())) c *= 2 ans = 10 ** 16 for i in range(max(x,y)+1): m = 0 m += (a*(max(0,x-i)))+(b*(max(0,y-i)))+(c*i) ans = min(ans,m) print(ans)
p03371
a, b, c, x, y = list(map(int, input().split())) res = a * x + b * y for i in range(1, max(x, y) + 1): res = min(res, a * max(x - i, 0) + b * max(y - i, 0) + 2 * c * i) print(res)
A, B, C, X, Y = list(map(int, input().split())) res = A*X + B*Y for i in range(max(X,Y)): if i >= X: res = min(res-B+2*C,res) elif i >= Y: res = min(res-A+2*C,res) else: res = min(res-A-B+2*C,res) print(res)
p03371
A, B, C, X, Y = list(map(int, input().split())) ans = 10**18 for ab in range(max(X, Y) * 2 + 10): a = max(0, X - ab // 2) b = max(0, Y - ab // 2) ans = min(ans, A * a + B * b + C * ab) print(ans)
A, B, C, X, Y = list(map(int, input().split())) ans = 10**18 for c in range(max(X, Y) * 2 + 1): x = max(0, X - c // 2) y = max(0, Y - c // 2) ans = min(ans, x * A + y * B + c * C) print(ans)
p03371
a,b,c,x,y=list(map(int,input().split())) ans=a*x+b*y for HaH in range(0,2*max(x,y)+1,2): ans = min(ans, c*HaH+max(0, a*(x-HaH//2))+max(0, b*(y-HaH//2))) print(ans)
a,b,c,x,y=list(map(int,input().split())) ans=0 m=min(x,y) if a+b>=2*c: #Half and Half購入で安くなる可能性あるパターン # HaHをm枚買って残りHaH購入,または全部HaH購入,このいずれかしかあり得ない ans = min(2*c*m+a*(x-m)+b*(y-m), 2*c*max(x,y)) else: ans = a*x+b*y print(ans)
p03371
def main(): A,B,C,X,Y = list(map(int, input().split())) min_cost = 2 * (10 ** 5) * max(A, B, C) for i in range(max(X, Y) + 1): num_c = 2 * (max(X, Y) - i) num_b = max(0, min(Y - num_c // 2, i)) num_a = max(0, min(X - num_c // 2, i)) total = A * num_a + B * num_b + C * num_c min_cost = min(total, min_cost) print(min_cost) if __name__ == "__main__": main()
def main(): A,B,C,X,Y = list(map(int, input().split())) min_cost = 2 * (10 ** 5) * max(A, B, C) for i in range(max(X, Y) + 1): num_c = 2 * (max(X, Y) - i) num_b = max(0, Y - num_c // 2) num_a = max(0, X - num_c // 2) total = A * num_a + B * num_b + C * num_c min_cost = min(total, min_cost) print(min_cost) if __name__ == "__main__": main()
p03371
# 095C import sys A,B,C,x,y = list(map(int, sys.stdin.readline().split())) ans = float('inf') for i in range(0, 2*max(x, y)+1, 2): tmp = A*max(x-i//2, 0) + C*i + B*max(y-i//2, 0) #print(tmp, i) if ans > tmp: ans = tmp print(ans)
#ABC095C def main(): import sys, math A,B,C,X,Y = list(map(int, sys.stdin.readline().split())) L =[] #全部C L.append(max(X, Y)*2*C) #できるだけC 不足分A,B if X <= Y: L +=[X*2*C + (Y-X)*B] else: L +=[Y*2*C + (X-Y)*A] #全部A,B L.append(A*X+B*Y) print((min(L))) if __name__=='__main__': main()
p03371
import sys from collections import deque from itertools import * def I(): return int(sys.stdin.readline().rstrip()) def LI(): return list(map(int, sys.stdin.readline().rstrip().split())) def S(): return sys.stdin.readline().rstrip() def LS(): return list(sys.stdin.readline().rstrip().split()) A, B, C, X, Y = LI() avg = (A+B)/2 ans = 0 if avg > C: ans += C * min(X, Y) * 2 if X > Y: if A > C * 2: ans += C * (X - Y) * 2 else: ans += A * (X - Y) elif X < Y: if B > C * 2: ans += C * (Y - X) * 2 else: ans += B * (Y - X) elif X == Y: pass else: ans = A * X + B * Y print(ans)
import sys def I(): return int(sys.stdin.readline().rstrip()) def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) def S(): return sys.stdin.readline().rstrip() def LS(): return list(sys.stdin.readline().rstrip().split()) A,B,C,X,Y = LI() ave = (A+B)/2 cost = 0 if ave > C: cost += C * min(X,Y) * 2 if X > Y: if A > C * 2: cost += C*2*(X-Y) else: cost += A*(X-Y) elif X < Y: if B > C * 2: cost += C*2*(Y-X) else: cost += B*(Y-X) else: cost += A*X + B*Y print(cost)
p03371
# -*- coding: utf-8 -*- import sys # 標準入力を取得 A, B, C, X, Y = list(map(int, input().split())) # 求解処理 ans = sys.maxsize max_c = 2 * max(X, Y) for c in range(0, max_c + 1, 2): a = max(X - c // 2, 0) b = max(Y - c // 2, 0) price = a * A + b * B + c * C ans = min(ans, price) # 結果出力 print(ans)
# -*- coding: utf-8 -*- import sys def get_input() -> tuple: """ 標準入力を取得する. Returns:\n tuple: 標準入力 """ A, B, C, X, Y = list(map(int, input().split())) return A, B, C, X, Y def main(A: int, B: int, C: int, X: int, Y: int) -> None: """ メイン処理. Args:\n A (int): Aピザの値段 B (int): Bピザの値段 C (int): ABピザの値段 X (int): Aピザの必要枚数 Y (int): Bピザの必要枚数 """ # 求解処理 ans = sys.maxsize max_c = 2 * max(X, Y) for c in range(0, max_c + 1, 2): a = max(X - c // 2, 0) b = max(Y - c // 2, 0) price = a * A + b * B + c * C ans = min(ans, price) # 結果出力 print(ans) if __name__ == "__main__": # 標準入力を取得 A, B, C, X, Y = get_input() # メイン処理 main(A, B, C, X, Y)
p03371
def main(): a, b, c, x, y = list(map(int, input().split())) total_min = a * x + b * y for i in range(2, max(x, y)*2+1, 2): total = a * max(x - i//2, 0) + b * max(y - i//2, 0) + c * i total_min = min(total, total_min) print(total_min) if __name__ == "__main__": main()
def main(): a, b, c, x, y = list(map(int, input().split())) total_min = a * x + b * y for i in range(1, max(x, y)+1): total = a * max(x - i, 0) + b * max(y - i, 0) + c * i * 2 total_min = min(total, total_min) print(total_min) if __name__ == "__main__": main()
p03371
a, b, c, x, y = list(map(int, input().split())) ab = c * 2 res = float("inf") if a + b <= ab: res = x * a + y * b else: if x == y: res = x * ab elif x > y: for i in range(y, x + 1): cost = i * ab + (x - i) * a res = min(res, cost) else: for i in range(x, y + 1): cost = i * ab + (y - i) * b res = min(res, cost) print(res)
import sys sys.setrecursionlimit(10 ** 7) input = sys.stdin.readline f_inf = float('inf') mod = 10 ** 9 + 7 def resolve(): a, b, c, x, y = list(map(int, input().split())) c *= 2 if a + b > c: cost1 = max(x, y) * c cost2 = min(x, y) * c plus = ((y - x) * b) if x < y else (x - y) * a res = min(cost1, cost2 + plus) else: res = x * a + y * b print(res) if __name__ == '__main__': resolve()
p03371
A, B, C, X, Y = list(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 else: 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)
A, B, C, X, Y = list(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 else: sum += A + B X -= 1 Y -= 1 else: if X > 0: if A > 2 * C: sum += 2 * C else: sum += A X -= 1 else: if B > 2 * C: sum += 2 * C else: sum += B Y -= 1 print(sum)
p03371
import sys stdin = sys.stdin ni = lambda: int(ns()) na = lambda: list(map(int, stdin.readline().split())) ns = lambda: stdin.readline().rstrip() nas = lambda: stdin.readline().split() a, b, c, x, y = na() ans = 0 while x or y: if x and y: if a + b > c * 2: x -= 1 y -= 1 ans += c * 2 else: x -= 1 y -= 1 ans += a + b else: q = c * 2 * (x + y) if q <= a * x + b * y: ans += c * 2 * (x + y) x = 0 y = 0 if x: ans += a * x x = 0 if y: ans += b * y y = 0 print(ans)
import sys stdin = sys.stdin ni = lambda: int(ns()) na = lambda: list(map(int, stdin.readline().split())) ns = lambda: stdin.readline().rstrip() nas = lambda: stdin.readline().split() a, b, c, x, y = na() ans = 0 while x or y: if x and y: if a + b > c * 2: z = min(x, y) x -= z y -= z ans += c * 2 * z else: z = min(x, y) x -= z y -= z ans += (a + b) * z else: q = c * 2 * (x + y) if q <= a * x + b * y: ans += c * 2 * (x + y) x = 0 y = 0 if x: ans += a * x x = 0 if y: ans += b * y y = 0 print(ans)
p03371
A, B, C, X, Y = list(map(int, input().split())) ans = X * A + Y * B for nab in range(2, max(X, Y) * 2 + 2, 2): price = nab * C price += max(X - (nab // 2), 0) * A price += max(Y - (nab // 2), 0) * B ans = min(ans, price) print(ans)
A, B, C, X, Y = list(map(int, input().split())) ans = None for ab_count in range(0, max(X, Y) * 2 + 1, 2): a_count = max(0, X - ab_count // 2) b_count = max(0, Y - ab_count // 2) amount = a_count * A + b_count * B + ab_count * C if ans is None: ans = amount else: ans = min(ans, amount) print(ans)
p03371
a, b, c, x, y = list(map(int, input().split())) res = a*x + b*y for i in range(1, max(x, y)+1): ab = i*2 cand = ab*c + a*max(0, x-i) + b*max(0, y-i) res = min(res, cand) print(res)
a,b,c,x,y = list(map(int, input().split())) ans = a*x + b*y for i in range(1, max(x,y)+1): C = 2*i*c + a*max(0,x-i) + b*max(0,y-i) ans = min(ans, C) print(ans)
p03371
# https://atcoder.jp/contests/abc095/tasks/arc096_a """ 別解(定数時間) https://atcoder.jp/contests/abc095/submissions/10226556 """ A,B,C,X,Y = list(map(int,input().split())) ans = float("inf") # ABピザを2枚1組で考える -> ABセット # i: ABセットの個数 for i in range(10**5 + 1): ans = min(ans, i*(2*C) + max(0, X-i)*A + max(0, Y-i)*B) print(ans)
A,B,C,X,Y = list(map(int,input().split())) AB_set = C * 2 ans = min(A*X + B*Y, AB_set*max(X,Y), AB_set*min(X,Y) + A*abs(X-min(X,Y)) + B*abs(Y-min(X,Y))) print(ans)
p03371
a, b, c, x, y = list(map(int, input().split())) val = float('inf') for k in range(10 ** 5 + 1): val = min(val, 2 * c * k + max(x - k, 0) * a + max(y - k, 0) * b) print(val)
A, B, C, X, Y = list(map(int, input().split())) ans = 0 ans += min(A + B, 2 * C) * min(X, Y) if X > Y: ans += min(A, 2 * C) * (X - Y) elif X < Y: ans += min(B, 2 * C) * (Y - X) print(ans)
p03371
inf = (5000 * 10 ** 5) * 3 a, b, c, x, y = list(map(int, input().split())) ret = inf for cnt_ab in range(max(x, y) * 2 + 1): d = cnt_ab // 2 cnt_a = max(0, x - d) cnt_b = max(0, y - d) t = cnt_ab * c + cnt_a * a + cnt_b * b ret = min(ret, t) print(ret)
def main(): A, B, AB, X, Y = list(map(int, input().split())) M = max(X, Y) k = 0 ans = A * X + B * Y while True: ans = min( ans, AB * k * 2 + max(0, X - k) * A + max(0, Y - k) * B ) if k >= M: break k += 1 print(ans) if __name__ == '__main__': main()
p03371
def main(): A, B, AB, X, Y = list(map(int, input().split())) M = max(X, Y) k = 0 ans = A * X + B * Y while True: ans = min( ans, AB * k * 2 + max(0, X - k) * A + max(0, Y - k) * B ) if k >= M: break k += 1 print(ans) if __name__ == '__main__': main()
def main(): A, B, C, X, Y = list(map(int, input().split())) ans = 1 << 30 c = 0 # even while True: j = c // 2 t = A * max(0, X - j) + B * max(0, Y - j) + C * c if ans <= t: break ans = t c += 2 print(ans) if __name__ == '__main__': main()
p03371
import sys sys.setrecursionlimit(10 ** 6) # input = sys.stdin.readline #### int1 = lambda x: int(x) - 1 def II(): return int(eval(input())) def MI(): return list(map(int, input().split())) def MI1(): return list(map(int1, input().split())) def LI(): return list(map(int, input().split())) def LI1(): return list(map(int1, input().split())) def LLI(rows_number): return [LI() for _ in range(rows_number)] def printlist(lst, k='\n'): print((k.join(list(map(str, lst))))) INF = float('inf') def solve(): a, b, c, x, y = MI() ans = INF for k in range(100001): yen = 2 * c * k + max(0, x-k) * a + max(0, y-k) * b ans = min(ans, yen) print(ans) if __name__ == '__main__': solve()
import sys sys.setrecursionlimit(10 ** 6) # input = sys.stdin.readline #### int1 = lambda x: int(x) - 1 def II(): return int(eval(input())) def MI(): return list(map(int, input().split())) def MI1(): return list(map(int1, input().split())) def LI(): return list(map(int, input().split())) def LI1(): return list(map(int1, input().split())) def LLI(rows_number): return [LI() for _ in range(rows_number)] def printlist(lst, k='\n'): print((k.join(list(map(str, lst))))) INF = float('inf') def solve(): a, b, c, x, y = MI() ans = 0 if a + b <= 2 * c: mn = min(x, y) ans = a * mn + b * mn + max(0, x-mn) * min(a, 2*c) + max(0, y-mn) * min(b, 2*c) else: mn = min(x, y) ans = mn * 2 * c + max(0, x-mn) * min(a, 2*c) + max(0, y-mn) * min(b, 2*c) print(ans) if __name__ == '__main__': solve()
p03371
a,b,c,x,y=list(map(int,input().split())) yenmin=a*x+b*y for zz in range(2*10**5+1): xx=max(x-zz//2,0) yy=max(y-zz//2,0) yen=a*xx+b*yy+c*zz if yen<yenmin: yenmin=yen print(yenmin) #print(xx,yy,zz)
a,b,c,x,y=list(map(int,input().split())) cmax=max(x,y)*2 zmin=(a+b)*10**5 for nc in range(0,cmax+1,2): na=max(x-nc//2,0) nb=max(y-nc//2,0) z=a*na+b*nb+c*nc zmin=min(zmin,z) print(zmin)
p03371
A, B, C, X, Y = list(map(int, input().split())) # Cを買った個数とA、B単品で買った場合のコストを愚直に試す total = 1<<60 for i in range(10**5+1): cost = 2*C*i + max(X-i, 0)*A + max(Y-i, 0)*B total = min(cost, total) print(total)
A, B, C, X, Y = list(map(int, input().split())) if (A+B) <= 2*C: # 単品だけで購入 print((X*A + Y*B)) else: # ABを買い残りを単品で補う if X >= Y: # ABでYは賄える print((min(X*2*C, Y*2*C + A*(X-Y)))) else: # ABでXは賄える print((min(Y*2*C, X*(2*C)+B*(Y-X))))
p03371
#!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 def LI(): return list(map(int, sys.stdin.readline().split())) def I(): return int(sys.stdin.readline()) def LS():return list(map(list, sys.stdin.readline().split())) def S(): return list(sys.stdin.readline())[:-1] def IR(n): l = [None for i in range(n)] for i in range(n):l[i] = I() return l def LIR(n): l = [None for i in range(n)] for i in range(n):l[i] = LI() return l def SR(n): l = [None for i in range(n)] for i in range(n):l[i] = S() return l def LSR(n): l = [None for i in range(n)] for i in range(n):l[i] = LS() return l sys.setrecursionlimit(1000000) mod = 1000000007 #A def A(): return #B def B(): return #C def C(): return #D def D(): return #E def E(): return #F def F(): a,b,c,X,Y = LI() ans = float("inf") for z in range(300001): if z%2 == 0: m = c*z x = z//2 y = z//2 m += a*max(0,X-x) m += b*max(0,Y-y) if m < ans: ans = m print(ans) return #G def G(): n = I() x = LI() f = [(i,x[i]) for i in range(n)] f.sort(key = lambda x:x[1]) g = [(f[i][0],i) for i in range(n)] g.sort(key = lambda x:x[0]) for i in range(n): if g[i][1] < n//2: print((f[n//2][1])) else: print((f[n//2-1][1])) return #H def H(): return #I def I_(): return #J def J(): return #Solve if __name__ == "__main__": F()
#!usr/bin/env python3 from collections import defaultdict,deque from heapq import heappush, heappop from itertools import permutations import sys import math import bisect def LI(): return [int(x) for x in sys.stdin.readline().split()] def I(): return int(sys.stdin.readline()) def LS():return [list(x) for x in sys.stdin.readline().split()] def S(): res = list(sys.stdin.readline()) if res[-1] == "\n": return res[:-1] return res def IR(n): return [I() for i in range(n)] def LIR(n): return [LI() for i in range(n)] def SR(n): return [S() for i in range(n)] def LSR(n): return [LS() for i in range(n)] sys.setrecursionlimit(1000000) mod = 1000000007 def solve(): A,B,C,x,y = LI() ans = float("inf") for c in range(200001)[::2]: a = b = c >> 1 a = max(0,x-a) b = max(0,y-b) s = A*a+B*b+C*c if s < ans: ans = s print(ans) return #Solve if __name__ == "__main__": solve()
p03371
#!/usr/bin/env python3 def main(): (A,B,C,X,Y) = list(map(int,input().split())) lim = max(X, Y) vmin = min(X, Y) minCost = 5000 * 10**5 * 2 for t in range(lim+1): if t <= vmin: cost = (X - t) * A + (Y - t) * B + t * 2 * C elif X <= Y: cost = (Y - t) * B + t * 2 * C else: cost = (X - t) * A + t * 2 * C minCost = min(minCost, cost) print(minCost) main()
def main(): (A,B,C,X,Y) = list(map(int,input().split())) if X < Y: X, Y = Y, X A, B = B, A print((min(A + B, 2 * C) * Y + min(A, 2*C) * (X - Y))) main()
p03371
a, b, c, x, y = list(map(int, input().split())) if a+b <= c*2: print((a*x+b*y)) else: ans = 10**9 for i in range(min(x,y)*2, 1+max(x,y)*2, 2): xx = x-i/2 if x-i/2 >= 0 else 0 yy = y-i/2 if y-i/2 >= 0 else 0 ans = min(ans, int(a*xx+b*yy+c*i)) print(ans)
a, b, c, x, y = list(map(int, input().split())) print((min(a*x+b*y, c*2*x+b*max(0,y-x), c*2*y+a*max(0,x-y))))
p03371
a, b, c, x, y = list(map(int, input().split())) print((min(a*x+b*y, c*2*x+b*max(0,y-x), c*2*y+a*max(0,x-y))))
a, b, c, x, y = list(map(int, input().split())) print((min(a*x+b*y, a*max(x-y, 0)+b*max(y-x, 0)+c*2*min(x, y), c*2*max(x, y))))
p03371
A,B,C,X,Y = list(map(int,input().split())) achete_A = 0 achete_B = 0 price = 10**100 C = 2 * C #=A,B for i in range(0,10**5+1): price = min(price,i*C + A*max(0,X-i) + B * max(0,Y-i)) print(price)
import sys from sys import stdin def input(): return stdin.readline().rstrip() def mips(): return list(map(int, input().split())) def ii(): return int(eval(input())) A, B, C, X, Y = mips() money = 0 while X > 0 and Y > 0: if (A+B) <= 2*C: money += (A+B) X -= 1 Y -= 1 else: money += 2*C X -= 1 Y -= 1 while X > 0: if A <= 2*C: money += A X -= 1 else: money += 2*C X -= 1 Y -= 1 while Y > 0: if B <= 2*C: money += B Y -= 1 else: money += 2*C X -= 1 Y -= 1 print(money)
p03371
A,B,C,X,Y=list(map(int,input().split())) if A>=2*C: if B>=2*C: print((2*C*max(X,Y))) exit() else: print((2*C*X+B*max(0,(Y-X)))) exit() elif B>=2*C: print((2*C*Y+A*max(0,(X-Y)))) exit() else: ans=A*X+B*Y for p in range(X): for q in range(Y): r=max(2*(X-p),2*(Y-q)) ans=min(ans,A*p+B*q+C*r) print(ans)
A,B,C,X,Y=list(map(int,input().split())) if A>=2*C: if B>=2*C: print((2*C*max(X,Y))) exit() else: print((2*C*X+B*max(0,(Y-X)))) exit() elif B>=2*C: print((2*C*Y+A*max(0,(X-Y)))) exit() else: ans=A*X+B*Y for i in range(1,min(X,Y)+1): p=A*(X-i)+B*(Y-i)+2*C*i ans=min(ans,p) print(ans)
p03371
A,B,C,X,Y=list(map(int,input().split())) if A>=2*C: if B>=2*C: print((2*C*max(X,Y))) exit() else: print((2*C*X+B*max(0,(Y-X)))) exit() elif B>=2*C: print((2*C*Y+A*max(0,(X-Y)))) exit() else: ans=A*X+B*Y for i in range(1,min(X,Y)+1): p=A*(X-i)+B*(Y-i)+2*C*i ans=min(ans,p) print(ans)
A,B,C,X,Y=list(map(int,input().split())) print((min(min(2*C*max(X,Y),A*X+B*Y),min(2*C*X+B*max(Y-X,0),A*max(X-Y,0)+2*C*Y))))
p03371
A, B, C, X, Y = list(map(int, input().split())) print((min(A*X+B*Y, min(X, Y)*C*2 + (X-min(X, Y))*A+(Y-min(X, Y))*B, max(X, Y)*C*2)))
A, B, C, X, Y = list(map(int, input().split())) cost_1 = A*X + B*Y cost_2 = C * max(X, Y) * 2 cost_3 = C * min(X, Y) * 2 + (X - min(X, Y))*A + (Y - min(X, Y))*B print((min(cost_1, cost_2, cost_3)))
p03371
A,B,C,X,Y = list(map(int, input().split())) ans = A*X+B*Y for k in range(2*max(X,Y)+1): ans = min(ans,2*C*k+A*max(0,X-k)+B*max(0,Y-k)) print(ans)
A, B, C, X, Y = list(map(int,input().split())) ans = A*X + B*Y for k in range(X+Y+1): ans = min(ans,A*max(0,X-k)+B*max(0,Y-k)+2*k*C) print(ans)
p03371
# -*- coding: utf-8 -*- """ Created on Tue Mar 31 11:16:07 2020 @author: liang """ A, B, C, X, Y = list(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)
# -*- 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 = list(map(int,input().split())) if A + B > 2*C: ans1 = max(X,Y) * C * 2 #条件分岐が減る if X > Y : ans2 = Y * C * 2 + abs(X-Y) * A else: ans2 = X * C * 2 + abs(X-Y) * B print((min(ans1,ans2))) #print()が分岐する else: ans1 = X * A + Y * B print(ans1)
p03371
a,b,c,x,y=list(map(int,input().split())) if a+b<=2*c: print((a*x+b*y)) else: print((c*2*min(x,y)+min(max(a*(x-y),b*(y-x)),c*2*abs(x-y))))
a,b,c,x,y=list(map(int,input().split())) print((min(c*2*min(x,y)+min(max(a*(x-y),b*(y-x)),c*2*abs(x-y)),a*x+b*y)))
p03371
a,b,c,x,y=list(map(int,input().split())) print((min(c*2*min(x,y)+min(max(a*(x-y),b*(y-x)),c*2*abs(x-y)),a*x+b*y)))
a,b,c,x,y=list(map(int,input().split())) d= a*x+b*y e= 2*c*x+b*max(0,y-x) #yが多い f= 2*c*y+a*max(0,x-y) #xが多い print((min(d,e,f)))
p03371
a,b,c,x,y = list(map(int,input().split())) ab = min(a+b, c*2) if x>y: tmp, tmp2, tmp3 = y, (x-y)*a, (x-y)*ab else: tmp, tmp2, tmp3 = x, (y-x)*b, (y-x)*ab ans = 0 for i in range(tmp): ans += ab print((ans+min(tmp2, tmp3)))
a, b, c, x, y = list(map(int, input().split())) ab = c*2 if a+b > ab: t = ab*min(x,y) d = max(x,y)-min(x,y) if x>y: dd = a*d else: dd = b*d print((t+ab*d if dd>ab*d else t+dd)) else: print((a*x+b*y))
p03371
A,B,C,X,Y = list(map(int,input().split())) if A+B>=2*C: ans = 2*C*min(X,Y) if X>=Y: ans += (X-Y)*min(A,2*C) else: ans += (Y-X)*min(B,2*C) else: ans = (A+B)*min(X,Y) if X>=Y: ans += (X-Y)*A else: ans += (Y-X)*B print(ans)
A,B,C,X,Y = list(map(int,input().split())) if 2*C<=A+B: if X<=Y: ans = 2*C*X ans += (Y-X)*min(B,2*C) else: ans = 2*C*Y ans += (X-Y)*min(A,2*C) else: if X<=Y: ans = (A+B)*X ans += (Y-X)*B else: ans = (A+B)*Y ans += (X-Y)*A print(ans)
p03371
A,B,C,X,Y = list(map(int,input().split())) if 2*C<=A+B: if X<=Y: ans = 2*C*X ans += (Y-X)*min(B,2*C) else: ans = 2*C*Y ans += (X-Y)*min(A,2*C) else: if X<=Y: ans = (A+B)*X ans += (Y-X)*B else: ans = (A+B)*Y ans += (X-Y)*A print(ans)
A,B,C,X,Y = list(map(int,input().split())) if X<=Y: ans = X*min(A+B,2*C) ans += (Y-X)*min(B,2*C) else: ans = Y*min(A+B,2*C) ans += (X-Y)*min(A,2*C) print(ans)
p03371
import sys input = lambda: sys.stdin.readline().rstrip() def resolve(): A, B, C, X, Y = list(map(int, input().split())) ans = float('inf') for i in range(0, max(X, Y)*2+1, 2): ans = min(A*max(X-i//2, 0)+B*max(Y-i//2, 0)+C*i, ans) print(ans) if __name__ == '__main__': resolve()
import sys input = lambda: sys.stdin.readline().rstrip() def resolve(): A, B, C, X, Y = list(map(int, input().split())) ans = 0 if A+B > 2*C: ans = 2*C*min(X, Y)+min((A if X>Y else B)*abs(X-Y), 2*C*abs(X-Y)) else: ans = A*X+B*Y print(ans) if __name__ == '__main__': resolve()
p03371
A,B,C,X,Y = list(map(int, input().split())) ans = A*X+B*Y for i in range(max(X,Y)+1): ans = min(ans, A*max(X-i,0)+B*max(Y-i,0)+C*i*2) print(ans)
A,B,C,X,Y = list(map(int, input().split())) if A+B < 2*C: ans = A*X+B*Y else: XY = min(X,Y) ans = min(A*(X-XY) + B*(Y-XY) + 2*C*XY, 2*C*max(X,Y)) print(ans)
p03371
A,B,C,X,Y = list(map(int,input().split())) max_pizza=max(X,Y)#AピザとBピザのうち、必要な枚数の多い方のピザの枚数 ans=10E+10 for i in range(0,max_pizza*2+2,2):#ABピザをi枚買う(iは偶数) if (X-i/2)<=0 and (Y-i/2)>0: ans_kouho = B*(Y-i/2)+C*(i) elif (X-i/2)>0 and(Y-i/2)<=0: ans_kouho = A*(X-i/2)+C*(i) elif (X-i/2)<=0 and(Y-i/2)<=0: ans_kouho = C*(i) else: ans_kouho = A*(X-i/2)+B*(Y-i/2)+C*(i) if(ans_kouho<ans): ans = ans_kouho print((int(ans)))
A,B,C,X,Y = list(map(int,input().split())) max_pizza=max(X,Y)#AピザとBピザのうち、必要な枚数の多い方のピザの枚数 ans=10E+10 for i in range(0,max_pizza*2+2,2):#ABピザをi枚買う(iは偶数) #max_pizza*2+2の「+2」に注意。例えばrange(0,10,2) #のとき0,2,4,6,8までしか出てこない。(0,10+2,2)なら10まで出る if (X-i/2)<=0 and (Y-i/2)>0: ans_kouho = B*(Y-i/2)+C*(i) elif (X-i/2)>0 and(Y-i/2)<=0: ans_kouho = A*(X-i/2)+C*(i) elif (X-i/2)<=0 and(Y-i/2)<=0: ans_kouho = C*(i) else: ans_kouho = A*(X-i/2)+B*(Y-i/2)+C*(i) if(ans_kouho<ans): ans = ans_kouho print((int(ans)))
p03371
A, B, C, X, Y = list(map(int, input().split())) AB = A + B num_A = 0 num_B = 0 num_C = 0 ans_cost = 5000 * 2 * 10**5 if 2 * C > AB: num_A = X num_B = Y num_C = 0 ans_cost = int(A*num_A + B*num_B + C*num_C) else: min_C = min(X,Y) *2 max_C = max(X,Y) *2 for i in range(min_C, max_C+1, 2): num_A = X - i / 2 num_B = Y - i / 2 if num_A < 1: num_A = 0 if num_B < 1: num_B = 0 total_cost = int(A*num_A + B*num_B + C*i) if total_cost < ans_cost: ans_cost = total_cost print(ans_cost)
A, B, C, X, Y = list(map(int, input().split())) min_cost = 0 if X - Y > 0: temp_cost = 2 * C * Y temp_cost += A * (X - Y) temp_cost2 = 2 * C * X if temp_cost > temp_cost2: min_cost = temp_cost2 else: min_cost = temp_cost else: temp_cost = 2 * C * X temp_cost += B * (Y - X) temp_cost2 = 2 * C * Y if temp_cost > temp_cost2: min_cost = temp_cost2 else: min_cost = temp_cost temp_cost3 = A * X + B *Y if temp_cost3 < min_cost: min_cost = temp_cost3 print(min_cost)
p03371
if __name__ == "__main__": A, B, C, X, Y = list(map(int, input().split())) ans = 0 if (A + B) >= 2*C: # ABピザ2枚買ってAとBに分けた方がお得 if (A >= B): if (B >= 2*C): # 全部ABの方がお得 if X >= Y: ans += (2*C) * X print(ans) exit() else: ans += (2*C) * Y print(ans) exit() elif (A >= 2*C): # Aの分はABピザで買ったほうがお得 ans += (2*C) * X if Y >= X: ans += A * (Y - X) print(ans) exit() else: # 枚数が少ない方をABで買う if X >= Y: ans += (2*C) * Y ans += A * (X - Y) else: ans += (2*C) * X ans += B * (Y - X) print(ans) exit() else: if (A >= 2*C): if X >= Y: # 全部ABの方がお得 ans += (2*C) * X print(ans) exit() else: # 全部ABの方がお得 ans += (2*C) * Y print(ans) exit() elif (B >= 2*C): # Bの分はABピザで買ったほうがお得 ans += (2*C) * Y if X >= Y: ans += A * (X - Y) print(ans) exit() else: # 枚数が少ない方をABで買う if X >= Y: ans += (2*C) * Y ans += A * (X - Y) else: ans += (2*C) * X ans += B * (Y - X) print(ans) exit() else: # 普通に買ったほうがよい ans += A * X + B * Y print(ans) exit()
# -*- coding:utf-8 -*- # https://atcoder.jp/contests/abc095/tasks/arc096_a def solve(): A, B, C, X, Y = list(map(int, input().split())) ans = 0 # 用意するピザの少ない方をまず買う if A+B <= C*2: # 1枚ずつ買ったほうが安い場合 if X <= Y: ans += A*X + B*X else: ans += A*Y + B*Y else: # Cを2枚買った方が安い場合 ans += min(X, Y)*C*2 # 残りのピザを買う if X >= Y: if A <= C*2: ans += (X-Y)*A else: ans += (X-Y)*C*2 else: if B <= C*2: ans += (Y-X)*B else: ans += (Y-X)*C*2 print(ans) if __name__ == "__main__": solve()
p03371
A,B,C,X,Y=list(map(int,input().split())) K=10**9 for i in range(10**5+1): S=i*2*C+max(0,X-i)*A+max(0,Y-i)*B K=min(K,S) print(K)
A,B,C,X,Y=list(map(int,input().split())) a=min(X,Y)*min(A+B,2*C) a+=max(0,X-Y)*min(A,2*C) a+=max(0,Y-X)*min(B,2*C) print(a)
p03371
A,B,C,X,Y = list(map(int,input().split())) p_sum = [] for i in range(100001): p_sum.append(i*2*C + max(0,X-i)*A + max(0,Y-i)*B) print((min(p_sum)))
A,B,AB,X,Y = list(map(int,input().split())) p_sum = [] for i in range(10**5+1): p_sum.append(i*2*AB + max(0,X-i)*A + max(0,Y-i)*B) print((min(p_sum)))
p03371
a,b,c,x,y=list(map(int,input().split()));print((min(k*c*2+a*max(x-k,0)+b*max(y-k,0)for k in range(max(x,y)*3))))
a,b,c,x,y=list(map(int,input().split()));print((min(x*a+y*b,2*x*c+b*max(0,y-x),2*y*c+a*max(0,x-y))))
p03371
A, B, C, X, Y = list(map(int, input().split())) ans = 5000 * 2 * 10 ** 5 for i in range(10 ** 5 + 1): s = i * 2 * C + max(0, X - i) * A + max(0, Y - i) * B ans = min(ans, s) print(ans)
A, B, C, X, Y = list(map(int, input().split())) if X > Y: v = A else: v = B ans = min(A*X+B*Y, C*max(X, Y)*2, C*min(X,Y)*2+(max(X,Y)-min(X,Y))*v) print(ans)
p03371
def resolve(): a, b, c, x, y = list(map(int, input().split())) ans = a * x + b * y ans = min(ans, c * max(x, y) * 2) if x > y: ans = min(ans, 2 * c * y + a * (x - y)) else: ans = min(ans, 2 * c * x + b * (y - x)) print(ans) return if __name__ == "__main__": resolve()
def resolve(): a, b, c, x, y = list(map(int, input().split())) ans = a * x + b * y # A を AB で代替する ans = min(ans, c * x * 2 + max(0, b * (y - x))) # B を AB で代替する ans = min(ans, c * y * 2 + max(0, a * (x - y))) print(ans) return if __name__ == "__main__": resolve()
p03371
a, b, c, x, y = list(map(int, input().split())) ans = float("inf") for k in range(0, max(x, y)*2+1, 2): i = 0 if x-k//2 < 0 else x-k//2 j = 0 if y-k//2 < 0 else y-k//2 ans = min(ans, a*i+b*j+c*k) print(ans)
a, b, c, x, y = list(map(int, input().split())) ans = float("inf") for i in range(0, max(2*x, 2*y)+1, 2): na = 0 if x-i//2 < 0 else x-i//2 nb = 0 if y-i//2 < 0 else y-i//2 ans = min(ans, c*i + a*na + b*nb) print(ans)
p03371
A,B,C,X,Y = list(map(int,input().split())) ans = 10**12 for c in range(max(X,Y) + 1): cost = C*2*c a = max(0, X-c) b = max(0, Y-c) cost += A*a + B*b ans = min(cost, ans) print(ans)
A,B,C,X,Y = list(map(int,input().split())) ans = float('inf') for c in range(max(X,Y) + 1): tmp = c*2*C tmp += max(0,X-c)*A tmp += max(0,Y-c)*B ans = min(ans, tmp) print(ans)
p03371
A,B,C,X,Y = list(map(int,input().split())) ans = float('inf') for c in range(max(X,Y) + 1): tmp = c*2*C tmp += max(0,X-c)*A tmp += max(0,Y-c)*B ans = min(ans, tmp) print(ans)
A,B,C,X,Y = list(map(int,input().split())) m = max(X,Y) ans = float('inf') for i in range(m+1): p = i*2*C + max(0,(X-i)*A) + max(0,(Y-i)*B) ans = min(ans, p) print(ans)
p03371
A, B, C, X, Y = list(map(int, input().split())) ans = float('inf') for i in range(10 ** 5 + 1): ans = min(ans, A * max(X - i, 0) + B * max(Y - i, 0) + 2 * C * i) print(ans)
A, B, C, X, Y = list(map(int, input().split())) # ans = float('inf') # for i in range(10 ** 5 + 1): # ans = min(ans, A * max(X - i, 0) + B * max(Y - i, 0) + 2 * C * i) # print(ans) min_xy = min(X, Y) max_xy = max(X, Y) ans1 = 2 * C * min_xy + A * (X - min_xy) + B * (Y - min_xy) ans2 = A * X + B * Y ans3 = 2 * C * max_xy print((min(ans1, ans2, ans3)))
p03371
a, b, c, x, y = list(map(int, input().split())) z = max(x,y) * 2 min_sum = c * z for i in range(z): r = max(0, y - i) * b t = max(0, x - i) * a sum = c * i * 2 + r + t if sum < min_sum: min_sum = sum print(min_sum)
a,b,c,x,y = list(map(int, input().split())) plan_a = c * (2*x) + max(0, y-x) * b plan_b = c * (2*y) + max(0, x-y) * a plan_c = a * x + b * y print((min(plan_a, plan_b, plan_c)))
p03371
#python3 INF = int(1e9) def main(): a, b, c, x, y = list(map(int, input().split())) ans = INF for i in range(2*10**5+100): t = 2*c*i + max(x-i, 0) * a + max(y-i, 0) * b ans = min(ans, t) print(ans) main()
INF = int(1e5)+5 def main(): a, b, c, x, y = list(map(int, input().split())) ans = INF*INF 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()
p03371
a, b, c, x, y = list(map(int, input().split())) ans = 10 ** 15 for i in range(max(x, y) * 2 + 1): n = c * i * 2 + max(0, x - i) * a + max(0, y - i) * b ans = min(ans, n) print(ans)
a, b, c, x, y = list(map(int, input().split())) ans = 10 ** 15 for i in range(max(x, y) * 2 + 1): if x - i//2 < 0 and y - i//2 < 0: n = c * i elif x - i//2 < 0: n = c * i + (y - i//2) * b elif y - i//2 < 0: n = c * i + (x - i//2) * a else: n = c * i + (x - i//2) * a + (y - i//2) * b ans = min(ans, n) print(ans)
p03371
A, B, C, X, Y = list(map(int, input().split())) ans = min(A * X + B * Y, 2 * C * X + B * abs(X - Y), 2 * C * Y + A * abs(X - Y), 2 * C * max(X, Y)) print(ans)
A, B, C, X, Y = list(map(int, input().split())) ans = min(A * X + B * Y, 2 * C * max(X, Y), 2 * C * X + B * (Y - X) if X < Y else 2 * C * Y + A * (X - Y)) print(ans)
p03371
def main(): A, B, C, X, Y = list(map(int, input().split())) print(( min(A * X + B * Y, 2 * C * max(X, Y), 2 * C * min(X, Y) + (B if X < Y else A) * abs(X - Y)))) return main()
def main(): A, B, C, X, Y = list(map(int, input().split())) if 2 * C < A + B: print((min( 2 * C * max(X, Y), 2 * C * min(X, Y) + A * (X - min(X, Y)) + B * (Y - min(X, Y)) ))) else: print((A * X + B * Y)) return main()
p03371