My issue
for _ in range(int(input())):
n, k=map(int, input().split())
l=list(map(int, input().split()))
rem=0
for i in range(n-1):
if l[i]==k:
pass
elif l[i]>k:
rem=l[i]-k
l[i+1]+=rem
if l[-1]>=k:
ans=f"YES"
else:
ans=f"NO {n}"
elif l[i]<k:
ans=f"NO {i+1}"
break
print(ans), given all test cases are passed, but some test case missing, please help.
My code
for _ in range(int(input())):
n, k=map(int, input().split())
l=list(map(int, input().split()))
rem=0
for i in range(n-1):
if l[i]==k:
pass
elif l[i]>k:
rem=l[i]-k
l[i+1]+=rem
if l[-1]>=k:
ans=f"YES"
else:
ans=f"NO {n}"
elif l[i]<k:
ans=f"NO {i+1}"
break
print(ans)
Learning course: 1000 to 1400 difficulty problems
Problem Link: Chef Diet Practice Problem in - CodeChef