C++| Priority Queue | Greedy
What the question ask? so we have to assign ExtraStudent in such class that we"ll get maximum possible ratio . so How we"ll do this . We have to send ExtraStude
What the question ask? so we have to assign ExtraStudent in such class that we"ll get maximum possible ratio . so How we"ll do this . We have to send ExtraStudents to classes 1 by 1 according to their ratio(calculate the difference of all classes for 1 student) where we get more difference  we"ll send the student to that particular class. and again check the difference for the next student .\n```\nclass Solution {\npublic:\n    double maxAverageRatio(vector<vector<int>>& classes, int extraStudents) {\n        priority_queue<pair<double,pair<int,int>>>pq;\n        for(int i=0;i<classes.size();i++){\n             int var1 = classes[i][0] , var2 = classes[i][1];\n            double diff = (double)(var1+1)/(var2+1) - (double)(var1)/(var2);\n              pq.push({diff,{var1,var2}});\n        }\n        \n        while(extraStudents!=0){\n            int var1 = pq.top().second.first , var2 = pq.top().second.second;\n            var1++;\n            var2++;\n            double newdiff = (double)(var1+1)/(var2+1) - (double)(var1)/(var2);\n            pq.pop();\n             pq.push({newdiff,{var1,var2}});\n            extraStudents--;\n            \n        }\n        double ans = 0;\n        while(!pq.empty()){\n            ans += (double)(pq.top().second.first) /(pq.top().second.second);\n            pq.pop();\n        }\n         \n        return ans/classes.size();\n        \n    }\n};\n```
['C', 'Heap (Priority Queue)']