Help please

I’m compiling the code in other compilers its working fine giving output to each test case but while answering in codechef it shows error runtime error

Give us a link to code or post it here. Without looking at code, we cannot give the exact reason.

But my experience tells that most of times, its going out of index range while using arrays. Eg-

 1. for(i=0;i<=n;i++) //For array of size z, arr[n] is out of range.
 2. for(i=0;i<n;i++)
       {
           if(arr[i]==arr[i+1]) //Here at i=n-1, again arr[i+1]=arr[n]=Out of index=runtime error

I managed to get the submission you are refering to : CodeChef: Practical coding for everyone

You are getting run-time error because of a Segmentation fault, which is nothing but you accessing a index of array that doesn’t exist.

You have declared your arrays as:

float s[100],d[100],sg[100],fg[100],f[100],x,speed,aspeed,tim;

and storing values in it as :

for(i=0;i < t; i++)
{
       scanf("%f\t%f\t%f\t%f\t%f\t",&s[i],&sg[i],&fg[i],&d[i],&f[i]);
}

As it is given in constraints that t can be of range 10^5.

If you try to access any array element more than 100, you will get this run-time error. Which is what is happening when we enter value of t greater than 100.

You were getting no errors on your machine because you were using small sized inputs.

I hope this solves your query.

PS: You should post your snippet of code ( either directly, ideone link or codechef submission link) when asking questions regarding it.