ghjfkgkfgjkhlfjghknb

May 26th, 2024
694
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. class Cake:
2.     def __init__(self, price, volume, condition):
3.         self.price_gram = price / volume
4.         self.volume = volume
5.         self.con = condition
6.
7.     def __eq__(self, other):
8.         if isinstance(other, Cake):
9.             return self.price_gram == other.price_gram
10.         return False
11.
12.     def __lt__(self, other):
13.         if isinstance(other, Cake):
14.             return self.price_gram < other.price_gram
15.         return False
16.
17. def Calculate(data):
18.     result = 0
19.     for cake in data:
20.         if cake.volume > conditions[1]:
21.             if cake.con:
22.                 result += cake.price_gram * conditions[1]
23.                 return result
24.             else: continue
25.         else:
26.             result += cake.price_gram * cake.volume
27.             conditions[1] -= cake.volume
28.     return result
29.
30. conditions = list(map(int, input().split()))
31. data = []
32. for i in range(conditions[0]):
33.     auxiliary = input().split()
34.     data.append(Cake(int(auxiliary[0]), int(auxiliary[1]), auxiliary[2] == 'Д'))
35. data.sort(reverse=True)
36. print("{:.2f}".format(Calculate(data)))