Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Cake:
- def __init__(self, price, volume, condition):
- self.price_gram = price / volume
- self.volume = volume
- self.con = condition
- def __eq__(self, other):
- if isinstance(other, Cake):
- return self.price_gram == other.price_gram
- return False
- def __lt__(self, other):
- if isinstance(other, Cake):
- return self.price_gram < other.price_gram
- return False
- def Calculate(data):
- result = 0
- for cake in data:
- if cake.volume > conditions[1]:
- if cake.con:
- result += cake.price_gram * conditions[1]
- return result
- else: continue
- else:
- result += cake.price_gram * cake.volume
- conditions[1] -= cake.volume
- return result
- conditions = list(map(int, input().split()))
- data = []
- for i in range(conditions[0]):
- auxiliary = input().split()
- data.append(Cake(int(auxiliary[0]), int(auxiliary[1]), auxiliary[2] == 'Д'))
- data.sort(reverse=True)
- print("{:.2f}".format(Calculate(data)))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement