Editorial for T-Shirts

Remember to use this editorial only when stuck, and not to copy-paste code from it. Please be respectful to the problem author and editorialist.

Submitting an official solution before solving the problem yourself is a bannable offence.

We make the observation that every time we have a free T-shirt deal, we should redeem it for the most expensive T-shirt – that is, large if there are any, otherwise medium if there are any, otherwise small. An easy way to implement this is to put all T-shirts in sorted order inside a double-ended list and keep popping from both sides.

s,m,l = map(int,raw_input().split())
a,b,c = map(float,raw_input().split())
total = 0.0
costs = []
for i in range(s):
for i in range(m):
for i in range(l):
count = 0
while costs:
    total += costs.pop(0)
    count += 1
    if count % 3 ==0 and costs:
print format(total,".2f")


There are no comments at the moment.