Help me in solving DSSA13 problem

My issue

My code

# cook your dish here
def can_win_race(N, K, L, speeds):
    max_speed = max(speeds)
    
    if max_speed + K <= L:
        return "No"
    else:
        for speed in speeds[:-1]:
            if max_speed - speed > K:
                return "No"
        return "Yes"

T = int(input())

for _ in range(T):
    N, K, L = map(int, input().split())
    speeds = list(map(int, input().split()))
    
    result = can_win_race(N, K, L, speeds)
    print(result)

Learning course: Kalasalingam Academy of Research and Education
Problem Link: CodeChef: Practical coding for everyone