Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- s, n = map(int, input().split())
- a = []
- for i in range(n):
- a.append(int(input()))
- a = sorted(a)
- i = 0
- count = 0
- while i < n and s >= a[i]:
- count += 1
- s -= a[i]
- i += 1
- print(count)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement