Sponsored
Sponsored
Use these hints if you're stuck. Try solving on your own first.
Notice that if a spell and potion pair is successful, then the spell and all stronger potions will be successful too.
Thus, for each spell, we need to find the potion with the least strength that will form a successful pair.
We can efficiently do this by sorting the potions based on strength and using binary search.