C++ using priority queue
initial ratio for one class=x/y\nafter adding 1 child=(x+1)/(y+1)\nchange in ratio by adding one child=(y-x)/(y*(y+1))\nkeep removing and adding this ratio from
initial ratio for one class=x/y\nafter adding 1 child=(x+1)/(y+1)\nchange in ratio by adding one child=(y-x)/(y*(y+1))\nkeep removing and adding this ratio from priority queue for all the extra students\n```\nclass Solution {\npublic:\n    double maxAverageRatio(vector<vector<int>>& c, int e) {\n        priority_queue<pair<double,int>> pq;\n        int n=c.size();\n        for(int i=0;i<n;i++){\n            double v=(c[i][1]-c[i][0])*1.0/(((c[i][1])*1.0)*(c[i][1]+1));\n            if(v<1){\n            pq.push({v,i});}\n        }\n        while(e!=0){\n            auto p=pq.top();\n            pq.pop();\n            int id=p.second;\n            c[id][0]++;\n            c[id][1]++;\n            double v=(c[id][1]-c[id][0])*1.0/(((c[id][1])*1.0)*(c[id][1]+1));\n            if(v<1){\n            pq.push({v,id});}\n            e--;\n            \n        }\n        double ans=0;\n        for(int i=0;i<n;i++){\n            ans+=((c[i][0]*1.0)/c[i][1]);\n        }\n        ans/=n;\n        return ans;\n        \n    }\n};\n```
[]