Explained briefly 
Intuition
The goal is to maximize the average pass ratio across all classes by strategically assigning the extra students. To achieve this, we should prioritize
**Intuition**\nThe goal is to maximize the average pass ratio across all classes by strategically assigning the extra students. To achieve this, we should prioritize adding students to the classes that yield the highest incremental gain in their pass ratios.\n\nThe incremental gain for a class depends on its current pass and total values. A max-heap can help us efficiently select the class with the largest gain after adding an extra student.\n\n**Approach**\nIncremental Gain Calculation:\nFor a class \u200Btotal students, adding one student updates the pass ratio. The incremental gain is:\ndouble diffinpassratio=(double)(pass+1)/(total+1)-(double)(pass)/(total);\nUsing a Max-Heap:\nExtract the class with the maximum gain, update its pass and total values after adding a student, and push the updated class back into the heap.\nAllocate Students:\nIteratively allocate all extra students to the classes that maximize the average pass ratio.\nCalculate Final Average Pass Ratio:\nAfter assigning all extra students, compute the average pass ratio by summing up the pass ratios of all classes and dividing by the number of classes.\n\n\n# Code\n```cpp []\nclass Solution {\npublic:\n    double maxAverageRatio(vector<vector<int>>& classes, int extraStudents) {\n        priority_queue<pair<double,pair<int,int>>>pq;//max heap of diff and class index\n        for(int i=0;i<classes.size();i++)\n        {\n            int pass=classes[i][0];\n            int total=classes[i][1];\n            double diffinpassratio=(double)(pass+1)/(total+1)-(double)(pass)/(total);\n            pq.push({diffinpassratio,{pass,total}});\n        }\n        while(extraStudents--)\n        {\n            int pass=pq.top().second.first;\n            int total=pq.top().second.second;\n            pass++;\n            total++;\n            pq.pop();\n            double newdiff=(double)(pass+1)/(total+1)-(double)(pass)/(total);\n            pq.push({newdiff,{pass,total}});\n        }\n        double totalaverage=0;\n        while(!pq.empty())\n        {\n            int pass=pq.top().second.first;\n            int total=pq.top().second.second;\n            pq.pop();\n            totalaverage+=(double)(pass)/(total);\n        }\n        return totalaverage/classes.size();\n    }\n};\n```
['Heap (Priority Queue)', 'C++']