TLG:why is it giving a wrong answer in codechef while it is successfully running in codeblocks?


#include<stdio.h>
#include<stdlib.h>

int main()
{
int n,i,j,d=0,max=0;

scanf("%d",&n);

int A[10000][2],L[10000][2];

for(i=0;i<n;i++)

{
    for(j=0;j<2;j++)
    {

scanf("%d",&A[i][j]);
    }
}

for(i=0;i<n;i++)
{
    if(A[i][0]>A[i][1])
    {
    L[i][0]=A[i][0]-A[i][1];
    L[i][1]=1;
    }
    else
    {
    L[i][0]=A[i][1]-A[i][0];
    L[i][1]=2;
    }
}

for(i=0;i<n;i++)
   {

        if(L[i][0]>=max)
        {
            max=L[i][0];
            d=L[i][1];
        }
   }
printf("%d %d",d,max);

return 0;

}

check my answer on this link: http://discuss.codechef.com/questions/59566/what-am-i-missing-in-the-code-on-the-site-wwwideonecom-when-i-run-the-code-it-runs-fine-but-here-i-get-wrog-answer?page=1#59574

Seems you are committing same mistake… !!

thanx a lot :smiley:
i was doing the same mistake.
the program worked this time!!

most welcome… :slight_smile: