B - Potions Editorial by evima
Another solution from proposerYou can use binary search. In this setup with only one monster, this was unnecessary (it is not faster overall because of the time it takes to input the potions), but if there were hundreds of thousands of monsters, this would be the simplest solution.
Sample Implementation (Python)
import bisect
N, H, X = map(int, input().split())
P = list(map(int, input().split()))
print(bisect.bisect_left(P, X - H) + 1)
P.S. I proposed A, B, and E.
posted:
last update: