I solved my first Codechef problem and submitted it, but it shows judge error? I don’t understand what seems to be the problem?

Hi, this is the problem statement:

https://www.codechef.com/LP1TO201/problems/CHFRICH

I am still getting judge error while submission…

Regards.

The number of test cases can be as big as 21000. So, the size of all the arrays you declared in your solution should be at least 21000. Here’s an Accepted solution.

Hey bro, saw your solution to the problem. Just a constructive criticism, that is NOT the right way of handling the testcases.

Whenever you have testcases to answer, make sure that you put the logic in a loop.

For eg, lets say I have “t” testcases to solve for any random problem, then i would write the logic for one testcase and then wrap that logic in a loop which runs t times:

PROGRAM:

int t;

cin>>t;

while(t–){

// LOGIC TO SOLVE THE PROBLEM FOR A SINGLE TESTCASE

}

I hope that it helped, don’t worry! Since it is your first problem on codechef, you will probably get stuck. All the best on your journey of Competitive programming

Check the the input constraints properly. for example… input values may be from -10^5 to +10^5.

But your data type is storing values only from 0 to +10^5 (unsigned int). For this case also Judge error comes… Solution=> Check constraints and used proper data types in your code…