competition link- CodeChef: Practical coding for everyone

my code- #include

#include

using namespace std;

int main()

{ int n;

cin>>n;

int p1[n],p2[n],l1[n],l2[n];

int a=0,b=0, sum1=0,sum2=0;

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

cin>>p1[i]>>p2[i];

if(p1[i]>p2[i]){

l1[a]=p1[i]-p2[i];

a++;

}

else

l2[b]=p2[i]-p1[i];

b++;

}

sort(l1,l1+a);

sort(l2,l2+b-1);

if(l1[a-1]>l2[b-1]){

cout<<“1”;

cout<<" “<<l1[a-1];

}

else {

cout<<“2”;

cout<<” "<<l2[b-1];

}

return 0;

}