题解 | 吃糖果
吃糖果
https://www.nowcoder.com/practice/d358465f9e57475f8dff09fbe9b90cfd
import re
n, k = map(int, input().split(' '))
ai = list(map(int, input().split(' ')))
ai.sort()
total_sweet=0
result = 0
for ele in ai:
total_sweet = total_sweet + ele
if total_sweet > k:
break
result += 1
print(result)