Why am I getting a runtime error? I cannot see which test case the code is failing. Here is the problem: https://www.codechef.com/problems/BUYSWEET
Here is my code:
count = input()
info = []
for x in range(0, int(count)):
info.append([])
for y in range(0, 3):
info[x].append(input())
for case in info:
for var2 in range(0, len(case)):
case[var2] = [word.strip() for word in case[var2].split()]
case[var2] = [eval(i) for i in case[var2]]
overall = []
for var1 in range(0, case[0][0]):
overall.append(case[1][var1] - case[2][var1])
prices = case[1]
cashbacks = case[2]
bank = case[0][1]
total = 0
while True:
temp = []
for var in prices:
if var > bank:
temp.append(prices.index(var))
for index in temp:
overall.pop(index)
cashbacks.pop(index)
prices.pop(index)
if len(prices) == 0:
break
best = min(overall)
index = overall.index(best)
bank -= prices[index]
bank += cashbacks[index]
total += 1
print(total)