Python3 greedy algorithm
Greedy algorithm: for each step of adding a student, maximize the increment of average score\n\n\n    def maxAverageRatio(self, classes: List[List[int]], extraS
Greedy algorithm: for each step of adding a student, maximize the increment of average score\n\n```\n    def maxAverageRatio(self, classes: List[List[int]], extraStudents: int) -> float:\n        heap = [[-(p + 1) / (t + 1) + p / t, p / t, p, t] for p, t in classes]\n        heapq.heapify(heap)\n        while extraStudents:\n            neg_inc, ratio, p, t = heapq.heappop(heap)\n            p += 1\n            t += 1\n            heapq.heappush(heap, [-(p + 1) / (t + 1) + p / t, p / t, p, t])\n            extraStudents -= 1\n        return sum(ele[1] for ele in heap) / len(heap)\n```
[]