Advertisement
Egor_1425

Untitled

May 28th, 2024
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.20 KB | None | 0 0
  1. s, n = map(int, input().split())
  2. a = []
  3. for i in range(n):
  4.     a.append(int(input()))
  5. a = sorted(a)
  6. i = 0
  7. count = 0
  8. while i < n and s >= a[i]:
  9.     count += 1
  10.     s -= a[i]
  11.     i += 1
  12. print(count)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement