This is my code showing correct output but showing the wrong answer on while submitting can anyone help
this is the code for “The lead game”
Input
5
140 82
89 134
90 110
112 106
88 90
Output
1 58
My code:-
#include<bits/stdc++.h>
using namespace std;
int main()
{
int x;
cin>>x;
int arr[x][2], temp, ans=0;
int arr1[x][2];
for(int i=0;i<x;i++)
for(int j=0;j<2;j++)
cin>>arr[i][j];
for(int i=0;i<x;i++)
{
while(1)
{
if((arr[i][0]-arr[i][1])>0)
{
arr1[i][0]=1;
arr1[i][1]=arr[i][0]-arr[i][1];
break;
}
else if((arr[i][0]-arr[i][1])<0)
{
arr1[i][0]=2;
arr1[i][1]=arr[i][1]-arr[i][0];
break;
}
else
{
arr1[i][1]=arr1[i][0]=0;
break;
}
}
}
temp=arr1[0][1];
for(int i=0;i<x;i++)
{
if(arr1[i][1]>temp)
ans=i;
}
cout<<arr1[ans][0]<<" "<<arr1[ans][1];
return 0;
}