CPP || easy to understand || best in world
IntuitionWe can use nested pair for it pair<increased_differnce,pair<value_at_subarray[0],value_at_subarray[1]>>Complexity
Time complexity:O(N)

Space complexit
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nWe can use nested pair for it pair<increased_differnce,pair<value_at_subarray[0],value_at_subarray[1]>>\n# Complexity\n- Time complexity:O(N)\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity:O(N)\n<!-- Add your space complexity here, e.g. $$O(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;\n        int n = classes.size();\n        for(int i=0;i<n;i++){\n            pq.push(make_pair((double)(classes[i][0]+1)/(double)(classes[i][1]+1) - (double)(classes[i][0])/(double)(classes[i][1]),make_pair(classes[i][0],classes[i][1])));\n        }\n        while(extraStudents--){\n            auto topa = pq.top();\n            topa.second.first = topa.second.first + 1;\n            topa.second.second = topa.second.second + 1;\n            topa.first = (double)(topa.second.first+1)/(double)(topa.second.second+1)-(double)(topa.second.first)/(double)(topa.second.second);\n            pq.pop();\n            pq.push(topa);\n        }\n        double avga = 0;\n        while(!pq.empty()){\n            auto topa = pq.top();\n            avga += (double)(topa.second.first)/(double)(topa.second.second);\n            pq.pop();\n        }\n        return (double)avga/(double)(n);\n    }\n};\n```
['Array', 'Greedy', 'Heap (Priority Queue)', 'C++']