TLG - Editorial

What’s wrong with my solution…

#include
using namespace std;

int main()
{
int i=0,l=0,w=0;
cin >> i;
while (i–)
{
int a,b,k=0;
cin>>a>>b;
if(a>b)
{
k = a-b;
}
else
{
k = b-a;
}
if(l <= k)
{
l = k;
if(a>b) w=1;
else w = 2;
}
}
cout<<w<<" "<<l;
return 0;
}

Here is the python code for TLG.

https://www.codechef.com/viewsolution/58012822

Please Check my code:
T = int(input())
Z = list()
for i in range(T):
X,Y = [int(i) for i in input().split()]
Z.append(X-Y)
if max(Z) > abs(min(Z)):
print(1,max(Z))
else:
print(2,abs(min(Z)))
Give me a suggestion What is wrong with this code>

cumu_score = []
lead = 0
for _ in range(int(input())):
p1,p2 =map(int,input().split())
diff = abs(p1 - p2)
if p1 > p2 :
cumu_score.append((1,diff))
else:
cumu_score.append((2,diff))

cumu_score.sort(key = lambda x: x[1])
w = cumu_score[len(cumu_score) - 1][0]
l = cumu_score[len(cumu_score) - 1][1]
print(w,l)

It work correctly. and pass many test cases. but still shows WA test case failed… don’t understand what’s going wrong.?