simple and intutive approach with comments
Intuition\nadd a single student in class which enhance the average maximum among them.\nthen update its new enhancment after adding a passed student\n\n# Approa
# Intuition\nadd a single student in class which enhance the average maximum among them.\nthen update its new enhancment after adding a passed student\n\n# Approach\nstore the profit of every class in max heap with its index\nupdate the profit of particular class where a student is added and\nupdate classes vector as well\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    double maxAverageRatio(vector<vector<int>>& classes, int k) {\n        double ans=0, n=classes.size(), i=0;\n        priority_queue<pair<double,int>> pq;\n        for(auto x:classes) \n        pq.push({((double)(x[0]+1)/(x[1]+1))-((double)(x[0])/(x[1])),i++});\n        // har class mi 1 pass student daal ke max heap mi arrange kar rahe hai \n        // ki kismi profit ho raha hai , WITH ITS INDEX;\n        while(k--)\n        {\n            int i=pq.top().second;\n            int p=classes[i][0]++, t=classes[i][1]++; //add 1 student in that class\n            pq.pop();\n            // ab uska new profit on adding a passes student daal denge\n            pq.push({((double)(p+2)/(t+2))-((double)(p+1)/(t+1)),i});           \n        }\n        for(auto x:classes)\n        {\n            ans+=((double)x[0])/x[1];\n        }\n        return ans/n;\n    }\n};\n```
['Greedy', 'Heap (Priority Queue)', 'C++']