python solution | heap |
\nclass Solution:\n    def maxAverageRatio(self, classes: List[List[int]], extraStudents: int) -> float:\n        h = []\n        n=len(classes)\n        \n    
```\nclass Solution:\n    def maxAverageRatio(self, classes: List[List[int]], extraStudents: int) -> float:\n        h = []\n        n=len(classes)\n        \n        \n        for i in classes:\n            currpassration = i[0]/i[1]\n            ifaddthan = (i[0]+1)/ (i[1]+1)\n            \n            increase = ifaddthan - currpassration\n            heappush(h,(-increase, currpassration,i[0],i[1]))\n            \n        heapify(h)\n        \n        while extraStudents:\n\n            a,curr,pas, tot = heappop(h)\n            a=-a            \n            curr +=a\n            ifaddthan = (pas+2)/(tot+2)\n            \n            increase = ifaddthan - curr\n            heappush(h, (-increase, curr, pas+1,tot+1))\n            \n            extraStudents-=1\n        \n        ps=0\n        tot=0\n        \n        while h:\n            a=h.pop()\n            ps+=a[1]\n        return ps/n\n            \n```
['Python', 'Python3']