Simple C++ Solution Priority Queue
\nclass Solution {\npublic:\n    double maxAverageRatio(vector<vector<int>>& classes, int extraStudents) {\n        priority_queue<pair<long double,pair<long lo
```\nclass Solution {\npublic:\n    double maxAverageRatio(vector<vector<int>>& classes, int extraStudents) {\n        priority_queue<pair<long double,pair<long long int,long long int>>>pq;\n        for(auto it:classes)\n        {\n            long long int z=(it[1]);\n            z=z*(it[1]+1);\n            long double pt=1.0*(it[1]-it[0])/z;\n            pq.push({pt,{it[0],it[1]}});\n        }\n        for(int i=0;i<extraStudents;i++)\n        {\n            long long int t1=pq.top().second.first+1;\n            long long int t2=pq.top().second.second+1;\n            long long int z=t2;\n            z=z*(t2+1);\n            long double g=1.0*(t2-t1)/z;\n            pq.pop();\n            pq.push({g,{t1,t2}});\n        }  \n        long double avg=0;\n        while(!pq.empty())\n        {\n            avg+=1.0*(pq.top().second.first)/(pq.top().second.second);\n            pq.pop();\n        }\n        return 1.0*avg/classes.size();\n    }\n};\n```
[]