FIRST TIME SUBMISSION IN CODECHEF Runtime error!!! Please help

Hi this is my first time trying to submit solution for the problem in codechef.
i had been through many issues (naming the file…) ,compilation, and now i’m stuck with

runtime error!

Anybody please help me why this error? whats the cause?
i tried java error!
http://www.codechef.com/viewsolution/1781464
then i thought maybe too much size then i moved to c, still its runtime error. http://www.codechef.com/viewsolution/1781670

Hey In your C code you should exit with code 0…i.e return 0 in the end and include header files neccesary.
In Java dont use packages…

I suggest you to just skim through this faq…

Also have a look on some of the sample solutions in various languages.

HAPPY CODING :slight_smile:

your solution has many problems…

1>you are not printing Output in Given format according to question
2>you are using Scanner which is not time efficient you should choose to use BufferedReader for not getting Time limit exceeded.
3> you have Runtime error because you are not return 0 at end of program which is NZEC error
for your convenience you can see following solution
[click for view solution][1]

here is your corrected solution
click to view your corrected solution

3 Likes

Thanks buddies, ("\n" too matters!). i got my solution correct.

why return 0 's required?
and why is it scanner time inefficient?

if (program_executed_fine)
return 0;

else if (program_had_error)
return 1;

0 is returned to the environment as a status that program worked fine.

Scanner when used opens a streams reads the input then close the stream… closing and opening of stream takes time in case of large input however in buffered reader stream is oopened once all the input is buffered and then used :)… you can http://www.codechef.com/problems/INTEST test the difference in this problem… Used with scanner the program will take more time

1 Like