My issue
T=int(input())
for i in range(T):
n,m=map(int,input().split())
bat=list(map(int,input().split()))
bowl=list(map(int,input().split()))
if n<4 or m<4 or n+m<11:
print(-1)
break
else:
bat.sort(reverse=True)
bowl.sort(reverse=True)
score=0
for x in range(3):
score+=bat+bowl
bat.pop(x)
bowl.pop(x)
batbowl=bat+bowl
batbowl.sort(reverse=True)
score+=batbowl[0]+batbowl[1]+batbowl[2]
print(score)
My code
# cook your dish here
T=int(input())
for i in range(T):
n,m=map(int,input().split())
bat=list(map(int,input().split()))
bowl=list(map(int,input().split()))
if n<4 or m<4 or n+m<11:
print(-1)
break
else:
bat.sort(reverse=True)
bowl.sort(reverse=True)
score=0
for x in range(3):
score+=bat[x]+bowl[x]
bat.pop(x)
bowl.pop(x)
batbowl=bat+bowl
batbowl.sort(reverse=True)
score+=batbowl[0]+batbowl[1]+batbowl[2]
print(score)
Traceback (most recent call last):
File "/mnt/sol.py", line 15, in <module>
score+=bat[x]+bowl[x]
~~~^^^
IndexError: list index out of range
Problem Link: GAME 11 Practice Coding Problem - CodeChef