Problem
A school has several classes. classes[i] = [pass_i, total_i] means class i has total_i students, of whom pass_i will pass the exam. You also have extra_students (extraStudents in TypeScript) brilliant students who are guaranteed to pass. You can place each of them into any class.
A class's pass ratio is pass / total. Assign every extra student to maximize the average pass ratio across all classes, and return that average.
Example 1
- Input
- classes = [[1, 2], [3, 5], [2, 2]], extra_students = 2
- Output
- 0.78333
Both extra students go to the first class: ratios become 3/4, 3/5, 2/2, averaging 0.78333. Answers within 10^-5 of the true value are accepted.
Constraints
1 <= classes.length <= 10^51 <= pass_i <= total_i <= 10^51 <= extra_students <= 10^5