# Help me in solving NODRUGS problem

### My issue

I’m getting a runtime error after submitting the code, but not while running it with the test input. Please help.

### My code

``````t = int(input())

for _ in range(t):
n, k, l = map(int, input().split())
s = list(map(int, input().split()))

friend_speed = s[n - 1]

s = s[:-1]
fastest = max(s)

success = True
for _ in range(len(s)):
if friend_speed + k * (l - 1) > s[_]:
continue
else:
success = False
if success:
print("Yes")
else:
print("No")
``````

Learning course: Jump from 2* to 3*
Problem Link: CodeChef: Practical coding for everyone

I wrote the same code in PHP and I got a runtime error there too. I don’t understand why it would show runtime error while submitting but not while running the test cases.

@mr_try_hard
plzz refer my c++ code.

``````#include <iostream>
#include <algorithm>
using namespace std;

int main() {
int t;
cin>>t;
while (t--)
{int n,k,l;
cin>>n>>k>>l;
l--;
int a[n];
for (int i=0;i<n;i++)
{cin>>a[i];}
int u=a[n-1];
//sort(a,a+n);
int ch=0;
int q=u+(k*l);
for(int i=0;i<n-1;i++)
{
if(u<=a[i])
{
ch=1;
break;
}
}
if(ch)
{
ch=0;
for(int i=0;i<n-1;i++)
{
if(q<=a[i])
{
ch=1;
break;
}
}
if(ch)
cout<<"No";
else
cout<<"Yes";
}
else
cout<<"Yes";
cout<<endl;
}
return 0;
}
``````

Ok, for some reason that I don’t understand the max function wasn’t working in Python or PHP. Removing it and just iterating through the array worked:

``````t = int(input())

for _ in range(t):
n, k, l = map(int, input().split())
s = list(map(int, input().split()))

friend_speed = s[n - 1]

s.pop()

success = True
if k < 0:
for _ in range(len(s)):
if friend_speed > s[_]:
continue
else:
success = False
break
else:
for _ in range(len(s)):
if friend_speed + k * ( l - 1) > s[_]:
continue
else:
success = False
break
if success:
print("Yes")
else:
print("No")
``````