I have tested my code for several inputs for the problem “The lead game”. Still not getting the error. Please help.
My code goes as follow :
def main():
a=[]
b=input()
while (b>0):
c,d=raw_input().split()
a.append(int(c)-int(d))
b=b-1
e=max(a)
f=min(a)*(-1)
if(e>f):
print "1",e
else:
print "2",f
if __name__ == "__main__":
main()
You are missing a small point in the question. Please, read the question carefully once.
"Consider the following score sheet for a game with 5 rounds:
Round Player 1 Player 2
1 140 82
2 89 134
3 90 110
4 112 106
5 88 90
The total scores of both players, the leader and the lead after
each round for this game is given below:
Round Player 1 Player 2 Leader Lead
1 140 82 Player 1 58
2 229 216 Player 1 13
3 319 326 Player 2 7
4 431 432 Player 2 1
5 519 522 Player 2 3
"
Particularly, at this point.
Thanks.
I am getting the right output for various test cases, Yet im not able to submit the solution.Please feel free to drop in your suggestions.
Heres,my code:
n=int(input())
lst1=[]
lst2=[]
for _ in range(n):
(a,b)=map(int,input().split(’ '))
c=a-b
if c>0:
lst1.append©
else:
lst2.append©
res = [abs(ele) for ele in lst2]
x=max(lst1)
y=max(res)
if(x>y):
print(1,x)
else:
print(2,y)
ssjgz
April 24, 2021, 8:08am
4
Please either format your code or (better!) link to your submission - the forum software has mangled it and it won’t compile!
Also, ensure your solution passes the testcase here .