[Python] Simple solution, explained, priority queue
\nimport heapq\n\nclass Solution:\n    def maxAverageRatio(self, classes: List[List[int]], extraStudents: int) -> float:\n        \n        # Organize the heap 
```\nimport heapq\n\nclass Solution:\n    def maxAverageRatio(self, classes: List[List[int]], extraStudents: int) -> float:\n        \n        # Organize the heap based on the "ratio improvement factor"\n        # i.e. The (new ratio) - (old ratio), the one that will improve the largest should be the one added to\n        # Add a negative since all heaps are minimum-oriented in python\n        classes = [[-((p+1)/(t+1) - (p/t)), p, t] for p, t in classes]\n        heapq.heapify(classes)\n        \n        # Go through the amount of students we need to add\n        for _ in range(extraStudents):\n            # Remove the next largest opportunity\n            c = heapq.heappop(classes)\n            \n            # Change all of the values\n            c[1] += 1\n            c[2] += 1\n            # Update ratio factor\n            c[0] = -((c[1]+1)/(c[2]+1) - (c[1]/c[2]))\n            # Push this back on to the heap\n            heapq.heappush(classes, c)\n            \n        # Calculate the total pass ratio after doing this\n        total_ratio = 0\n        n = 0\n        for c in sorted(classes):\n            n += 1\n            total_ratio += (c[1] / c[2])\n            \n        return total_ratio / n\n```
['Heap (Priority Queue)', 'Python3']