C# SortedSet
\npublic class Solution {\n    public double MaxAverageRatio(int[][] classes, int extraStudents) {\n        \n        var set = new SortedSet<(double delta, int
```\npublic class Solution {\n    public double MaxAverageRatio(int[][] classes, int extraStudents) {\n        \n        var set = new SortedSet<(double delta, int index, double pass, double total)>();\n        int index = 0;\n        \n        double avg = 0.0;\n        foreach(var cl in classes)\n        {\n            double a = cl[0], b = cl[1];\n            avg += a/b;              \n            set.Add((GetDeltaGain(a, b), index++, a + 1, b + 1)); //gotcha\n        }\n        \n        while(extraStudents-- > 0)\n        {            \n            var max = set.Max;\n            set.Remove(set.Max);            \n            avg += max.delta;\n            set.Add((GetDeltaGain(max.pass, max.total), index++, max.pass + 1, max.total + 1));           \n        }       \n       \n        return avg/classes.Length;\n    }\n    \n    private double GetDeltaGain(double a, double b)\n    {\n        return (a + 1)/(b + 1) - a/b; //gotcha gotcha gotcha -- BRACKETS\n    }\n}\n```
[]