Whats Wrong With The Code? It Result In Re In Google Kickstart 2020 Round A
What i am missing here in this code? It results in RE in Kickstart 2020 but when i test on my local machine or hackereath compiler(similar to codejam complier) code works fine. pro
Solution 1:
At the print statement in which use of f is resulting in RE.
In the print statement, you should use format to output i+1 and j.
To pass all the test cases you have to sort the array to calculate number of houses by the greedy method.
def solve(a,balance):
house_Can_buy=0
a.sort()
for i in a:
if i<=balance:
house_Can_buy+=1
balance-=i
return house_Can_buy
def main():
a=int(input())
arr2,res=[],[]
for i in range(a):
_,balance=list(map(int,input().split()))
arr2=list(map(int,input().split()))
result=solve(arr2,balance)
res.append(result)
for i,j in enumerate (res):
print('Case #{}: {}'.format(i+1,j))
main()
Post a Comment for "Whats Wrong With The Code? It Result In Re In Google Kickstart 2020 Round A"