class Solution:
def maxAverageRatio(self, classes: List[List[int]], e: int) -> float:
ans = 0
h = []
for p , t in classes:
ans += (p/t)
h.append((-(t - p)/(t * (t + 1.0)), t, p))
heapq.heapify(h)
while e:
v, t, p = heapq.heappop(h)
ans -= v
t += 1
p += 1
heapq.heappush(h, (-(t - p)/(t * (t + 1.0)), t, p))
e -= 1
return ans/len(classes)