Practice Maximum Average Pass Ratio
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
There is a school that has classes of students and each class will be having a final exam. You are given a 2D integer array classes, where classes[i] = [passi, totali]. You know beforehand that in the ith class, there are totali total students, but only passi number of students will pass the exam. You are also given an integer extraStudents. There are another extraStudents brilliant students that are guaranteed to pass the exam of any class they are assigned to. You want to assign each of the extraStudents students to a class in a way that maximizes the average pass ratio across all the classes. The pass ratio of a class is equal to the number of students of the class that will pass the exam divided by the total number of students of the class. The average pass ratio is the sum of pass ratios of all the classes divided by the number of the classes. Return the maximum possible average pass ratio after assigning the extraStudents students. Answers within 10^-5 of the actual answer will be accepted.
Source: Maximum Average Pass Ratio on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
classes = [[1,2],[3,5],[2,2]], extraStudents = 2
0.78333
# Example 2
classes = [[2,4],[3,9],[4,5],[2,10]], extraStudents = 4
0.53485
Constraints
Related LeetCode Problems
Practice more problems similar to Maximum Average Pass Ratio.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.