Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #https://inf-ege.sdamgia.ru/problem?id=27423
- data = open('26_demo.txt').readlines()
- s, n = map(int, data[0].split())
- a = list(map(int, data[1:]))
- a.sort()
- cur_s = 0
- cnt = 0
- for i in range(n):
- if a[i] + cur_s <= s:
- cur_s += a[i]
- cnt += 1
- print(cnt, end=' ')
- cur_s -= a[cnt - 1] #вычли последний
- answ = 0
- for i in range(cnt, n):
- if cur_s + a[i] <= s:
- answ = a[i]
- print(answ)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement