I just tried to solve google kickstart allocation question(round A). Can anyone help me what’s wrong in my code?
problem link-Kick Start - Google’s Coding Competitions
My code-
def maximum_toys(cost, N, K):
count = 0
sum = 0
cost.sort(reverse=False)
for i in range(0, N, 1):
if (sum + cost[i] <= K):
sum = sum + cost[i]
count += 1
return count
t = int(input())
for i in range(0, t):
n, b = [int(x) for x in input().split(" ")]
val = [int(x) for x in input().split(" ")]
N = len(val)
x=maximum_toys(val, N, b)
print("Case #{}".format(i+1),x)
It is showing Wrong Answer.