Simple and Beginner friendly || Priority Queue || Clean code  
Intuition

To maximize the average ratio of passed to total students in multiple classes after applying a given number of operations, we use a greedy strategy w
# Intuition\n1. To maximize the average ratio of passed to total students in multiple classes after applying a given number of operations, we use a greedy strategy with a priority queue (max-heap).\n\n2. Key Idea: Each operation adds 1 to both the passed and total students of a class. The impact of this operation is bigger when the class has fewer passed students compared to total students. Therefore, we want to prioritize classes where this gain is largest.\n\n\n# Approach\nGreedy Approach:\n\n1. Calculate the initial ratio for each class (passed[i] / total[i]).\n2. Use a priority queue to keep track of the class with the largest potential gain (difference in ratio before and after the operation).\n3. For each operation, apply it to the class with the largest gain and update its ratio.\n4. Final Calculation: After applying all operations, calculate the average ratio of passed students to total students across all classes\n\n\n# Complexity\n- Time complexity:\nO(n log n) -  to build the max-heap for the initial ratios.\nO(es log n) - to process the operations and update the heap.\nO(n) - to compute the final average ratio.\nTotal time complexity: O((n + es) log n).\n\n- Space complexity:\n O(n) \n\n# Code\n```cpp []\nclass Solution {\npublic:\n    double maxAverageRatio(vector<vector<int>>& classes, int es) {\n        priority_queue<pair<double, int>> maxheap;\n        vector<vector<int>> temp = classes;\n        double ans = 0.0;\n \n        for (int i = 0; i < classes.size(); i++) {\n            double ratio1 = (double)classes[i][0] / classes[i][1];\n            double ratio2 = (double)(classes[i][0] + 1) / (classes[i][1] + 1);\n            maxheap.push({ratio2 - ratio1, i});\n        }\n \n        while (es--) {\n            int idx = maxheap.top().second;\n            maxheap.pop();\n \n            temp[idx][0]++;\n            temp[idx][1]++; \n            double newchange1 = (double)temp[idx][0] / temp[idx][1];\n            double newchange2 = (double)(temp[idx][0] + 1) / (temp[idx][1] + 1);\n \n            maxheap.push({newchange2 - newchange1, idx});\n        }\n \n        double totratio = 0.0;\n        for (auto it : temp) {\n            totratio += (double)it[0] / it[1];\n        } \n        ans = totratio / temp.size();\n        return ans;\n    }\n};\n\n```
['Array', 'Greedy', 'Heap (Priority Queue)', 'C++']