One thing that trips up all people migrating from Hackerrank (hello :)) is that clicking “Run” (not “Submit”) here on Codechef does not run your code with the sample testcases - instead, it runs it with empty input (so attempts to read anything from stdin will fail, or give weird values). If you click “Run”, you must provide Custom Input.
Ha! Even I tripped on that the first time.
I think I spent about 10 minutes clicking Run and looking at my debug output and scratching my head the first time XD
did you press run?
That might explain why you got NZEC because you didn’t give any sample input
Read this post, it may help.
@gauraws import functools. Map is now in functools. This was done because GVR figured since coders can just do [func(x) for x in iterable] , map needn’t be a builtin function
This problem occurs because you didn’t provide the inputs to your code.
So please click on Custom Input checkbox
and then provide input, what you want then click on run.
Now you will good to go ; )
My code works fine with custom input(same input as in the problem description) but when I submit it says “Wrong answer”.Need help.
#Code
def uni():
global uniprob
for i in list:
if(i.prob_num<9):
uniprob.append(i.prob_num)
uniprob = set(uniprob)
class Test:
def init(self):
self.prob_num,self.score=(int(input()),int(input()))
Taking test case and submissions
try:
tcase = input()
tcase = int(tcase)
for _ in range(tcase):
uniprob =[]
list=[]
submis = int(input())
Creating a list of objects
for i in range(submis):
list.append(Test())
Global Scope
uni()
k=0
maxm=0
finalres=0
for k in uniprob:
for i in list:
if i.score>maxm and i.prob_num==k:
maxm = i.score
finalres = finalres+maxm
maxm=0
print(finalres)
except:
pass
Even me when I came from Hackerearth
gosh! that was it lol. I havent competed since 2012…feel so stupid
Hi,I am using python 3.6 lang, I clicked on custom input and it work fine when i click on run but the problem is coming when I am clicking on Submit Button it is always showing wrong answer.
while i have checked for solutions in other language and my solution is correct what to do?
https://www.codechef.com/viewsolution/32286114
Corrected it. Your code may sometimes print yes multiple times, so you also need to check that flag!=1
. Also you were not resetting flag after each test case.
Hi thank u so much .
Use try: and except: for python. It works for me.
For example:
try:
for t in range(int(input()):
n = int(input())
print(n)
except:
pass
if you want to test your code, give sample input and then click “RUN”. if you want to submit code, you just click “submit” button. NZEC error occurs when we click “RUN” without giving input
welcome to maturity.
Hi, I am actually new to codechef platform. Could you help me in overcoming error like
“Traceback (most recent call last):
File “./prog.py”, line 5, in
EOFError: EOF when reading a line”.
However, I ran the program with custom input.But, I couldn’t manage it while submitting. Could you please help me with this.Thankyou
That is when you have an input statement but nothing to read.
Maybe you can read this - https://stackoverflow.com/questions/17675925/eoferror-eof-when-reading-a-line
Google for more info.
Thankyou. I provided custom input while running. However, there was a small problem in my code and I’m done with it. Anyway, Thank you so much for your instant help and support.