Imagine you're an academic advisor at a prestigious school with the power to strategically place brilliant students to maximize the overall success rate across all classes! ๐
You have classes, where each class i currently has passi students who will pass out of totali total students. You also have extraStudents brilliant students who are guaranteed to pass any class they're assigned to.
Your mission: Assign these extra students to maximize the average pass ratio across all classes.
The pass ratio of a class = passing_students / total_students
The average pass ratio = sum of all pass ratios / number of classes
Key Insight: Adding a student to a class with a lower current ratio typically yields a bigger improvement than adding to a class with a higher ratio!
Return the maximum possible average pass ratio after optimally assigning all extra students.
Input & Output
Constraints
- 1 โค classes.length โค 105
- classes[i].length == 2
- 1 โค passi โค totali โค 105
- 1 โค extraStudents โค 105
- Answers within 10-5 of the actual answer will be accepted