What is wrong with my code? The Lead game -TLG

Here is the link for the problem

Could you please tell what is wrong with my solution.
#include
using namespace std;
int main()
{
int test;
cin>>test;
int a,b,w1=0,w2=0;
for(int i=0;i<test;i++)
{
cin>>a>>b;
if(a>b)
if(a-b>w1)
w1=a-b;
if(b>a)
if(b-a>w2)
w2=b-a;
}
if(w1>w2)
{
cout<<"1 "<<w1;
}
else
cout<<"2 "<<w2;
}

i too attempted the problem and mine was also displayed to be wrong. I dont know why. here is the source code

#include <iostream>
#include<cmath>

using namespace std;

int main()
{
    int n;
    cin>>n;
    int *p1,*p2;
    p1=new int[n];
    p2=new int[n];
    for(int i=0;i<n;i++)
    {
        cin>>p1[i]>>p2[i];
    }
    int large=0,temp_large=0,diff=0,temp_diff=0;
    for(int i=0;i<n;i++)
    {
        temp_diff=p1[i]-p2[i];
        if(diff==0)
        {
            diff=temp_diff;
        }
        if(temp_diff>0)
        {
            temp_large=1;
        }
        else
        {
            temp_large=2;
        }
        temp_diff=abs(temp_diff);
        if(temp_diff>=diff)
        {
            diff=temp_diff;
            large=temp_large;
        }

    }
    cout<<large<<" "<<diff;
}