Last time It's the 6th day. It is tax_free who lost to C of yesterday's contest.
#6 Problem
** Thoughts ** It is a problem to find the minimum value of the combination of A pizza, B pizza, and AB pizza. I solved it by specifying the number of AB in the for statement and updating the minimum value.
a, b, c, x, y = 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)
The initial value is the price when you bought 0 AB pizzas, and it is turned by for. Python for stops at a stop value of -1, so if you forget to add +1 you won't be able to buy all AB as in sample case 3.
c * 2 * i + max(a * (x - i),0) + max(b * (y - i),0))
When x <i or y <i, max (0, calculation result) is taken to prevent a * (x --i) and b * (y --i) from becoming negative. I will.
I wonder if I can do this much C. I want to be able to solve this much even in the actual contest see you
Recommended Posts