I dont think this works why are you assigning the weakest a pill and if that fails returning false
this does not run for tasks: [1, 8] workers: [3, 7] with pills=1 and strengths=4. Answer should be 2 but from your code it seems like answer would be 1.
@electricochy