i you know groups[i] = [p, t]: it has t students, and exactly p of them will pass. The group's pass rate is p / t.
There are also helpers new top students, each certain to pass in whichever group they join (adding 1 to both the group's size and its number of passers). Assign every one of them to a group so that the average of the pass rates across all groups is as large as possible, and return that average.
Answers within 10⁻⁵ of the exact value are accepted.groups=[[1, 3], [4, 4]], helpers=1 → 0.75
Everyone in the second group already passes, so the helper joins the first one: (2/4 + 4/4) / 2 = 0.75.
groups=[[2, 5], [1, 2]], helpers=2 → 0.5833333333333333
One helper per group is best: (3/6 + 2/3) / 2 ≈ 0.58333. Both in the first group give ≈ 0.53571, both in the second give 0.575.
groups=[[1, 3], [4, 4]], helpers=1
0.75
Run checks the first 3 tests in your browser. Submit checks all 101 tests on the server, hidden ones included.