cannot find what is wrong with this code of question link text . workng for most of the test cases i tried on my pc still getting wrong answer with codechef compiler . help !!
include<stdio.h>
int main()
{
int i,j,k,l,first,x=0,a,p=0,q=0,diff=0,n,b;
for(i=0;i<=n;i++)
{
if(i==0)
{
scanf("%d",&n);
}
else
{
scanf("%d",&a);
scanf("%d",&b);
p=p+a;
q=q+b;
if(p>q)
{
if(diff<(p-q))
{
diff=p-q;
x=1;
}
}
else
{
if(diff<(q-p))
{
diff=q-p;
x=2;
}
}
}
}
printf("%d %d",x,diff);
return 0;
}