Beginner problem t

this code of mine is executing well in codechef compliler but on submitting it is showing wrong answer. can sombody tell why ?

#include <stdio.h>
int main() {
int t,n,m,max=0,s=0,r=0,p,i;
scanf("%d",&t);
for(i=0;i<t;i++)
{
scanf("%d %d",&n,&m);
s=s+n;
r=r+m;
if(s>r && max<s-r)
{
max=s-r;
p=1;
}
else
{
max=r-s;
p=2;
}
}
printf("%d %d",p,max);
return 0;
}

May be it is not giving any error in codechef compiler because your program has no syntax error.
However your program was giving some answer but your answer was not same as required.

The LOGIC is wrong. Also, format your code before posting or share a link

There is no grammatical error, but it does not meet the requirements of the answer.

Your code run bcz there is no any syntax error in your code but when you submit then output is diffrent or wrong bcz
1)
may be you are using diffrent compiler, its simply means diffrent diffrent compiler gives diffrent diffrent answer.

  1. May be your logic is wrong.