Help me in solving DSSA13 problem

My issue

My code

# cook your dish here
t=int(input())
for i in range(t):
    a=0
    S=[]
    S_max=0
    L_c=1
    N,K,L=map(int,input().split())
    S=list(map(int,input().split()))
    ln=S[N-1]
    for i in range(N):
        if S[i]>S_max:
            S_max=S[i]
    if ln>S_max:
        print("Yes")
       
    else:
        if K<0:
            print("No")
            
        else:
            while(L>L_c):
                ln+=K
                L_c+=1
            if ln>S_max:
                print("Yes")
            else:
                print("No") 
            

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