My issue
i am getting a correct output still it is not a Correct answer according to the codechef compiler
My code
# cook your dish here
n = int(input())
Si=[]
Ti=[]
l1=[]
l2=[]
for a in range(n):
s,t=map(int,input().split())
Si.append(s)
Ti.append(t)
for i in range(n):
if Si[i]>Ti[i]:
l1.append(Si[i]-Ti[i])
else:
l2.append(Ti[i]-Si[i])
if max(l1) > max(l2):
print(1,max(l1))
else:
print(2,max(l2))
Problem Link: TLG Problem - CodeChef
@ashay21
your logic is not right .
plzz refer the following solution for better understanding of the logic.
n = int(input())
play1 = 0
play2 = 0
max1 = 0
max2 = 0
for _ in range(n):
a,b = map(int,input().split())
max1 += a
max2 += b
if max1>max2:
play1 = max(play1,max1-max2)
else:
play2 = max(play2,max2-max1)
if play1>play2:
print(1,play1)
else:
print(2,play2)
Can you please tell me exactly where I am going wrong with the logic in my code.
@ashay21
U have to keep summing sum the previous rounds scores too . then compare them .
Like i’m doing with max1 and max2.
Alright …I get it now. Thanks for your concern and Guidance