Help I am not able to run my code but can in vs code without any errors?

I am getting runtime error Nzec in my code but my code works fine in vs code. I am new to codechef Please help me out. This is my first problem in codechef. Please help me out in this error. Contest Code [SDPCB21] and Problem code is [QUALPREL]

t = input()
ls = []
ans = 0

if len(t) > 1:
    ls = list(map(int, t.split(' ')))
    for i in ls:
        ans += i
    
    print(ans)

else:
    print(int(t))

Is This Your Whole Solution Or Just The Snippet of The Main Function.
Because You Haven’t Added The Loop for Testcases.

#No Of TestCases
T = int(input())

#Iterating T times
for tc in range(T):
	N, K = input().split(" ")
	K = int(K)
#Logic
	scores = list(map(int, input().split(" ")))
	scores.sort(reverse=True)
	cuttoff = scores[K-1]
	scores.sort()
	print(len(scores)-scores.index(cuttoff))

What is a Testcases? i am new to this i was working in codewars before can you explain me?

2 Likes

I’m too new here.

Testcases Is Simply The Input Data Wich You Need To Process And Output The Appropriate Solution.
So “T” is Basically The No Of Times Your Code Will Execute/ be Checked.
Most of The Questions On Codechef Are Like This.

#No. Of Testcases
NT = int(input())
#for loop for handling the testcases
for testcases in range(NT):
    #your main Program

You Need To Create An Outermost Loop So Your Program Runs Exactly The No Of Times As The No of Input Data(Testcases).

1 Like