I was trying to solve Lecandy problem and I completed that problem in 0.03s and used up 17.3 mb space. Any suggestions on improving the code? I have used python3.
Here’s the link to the problem:-
Here’s my solution:-
def lecandy(c,a):
if c >= sum(a):
return “Yes”
else:
return “No”
t = int(input())
ans = []
for i in range(1, t+1):
n, c = map(int, input().split())
a = []
a = list(map(int, input().split()))
ans.append(lecandy(c, a))
if len(ans) != 0:
for i in ans:
print(i)
Any help is greatly appreciated.