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:]))
- if sum(a) <= s:
- print(n, max(a))
- exit(0)
- a.sort()
- cur_s = 0
- cnt = 0
- while cur_s <= s:
- cur_s += a[cnt]
- cnt += 1
- #cnt -= 1
- print(cnt, end=' ')
- #cur_s -= a[cnt] #вычли лишний
- cur_s -= a[cnt - 1] #вычли последний
- for i in range(cnt, n):
- if cur_s + a[i] > s:
- print(a[i - 1])
- break
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement