potions
array in ascending order.answer
to store the result for each spell.spell
in the spells
array:
a. Calculate minPotion
as ceil(success / spell)
.
b. Perform binary search on the sorted potions
array to find the index of the first potion that is greater than or equal to minPotion
.
c. The number of successful pairs for the spell is the count of potions from this index to the end.
d. Store this count in the answer
array.answer
array.