Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- with open('/Users/alex26/Downloads/26 (18).txt', 'r') as f:
- _, K, M = [int(f.readline()) for _ in range(3)]
- d = list(map(int, f.read().strip().split('\n')))
- d.sort(reverse=True)
- space = [M for _ in range(K)]
- last_idx = -1
- while True:
- last_idx += 1
- if last_idx == len(space) or not d:break
- d.sort(reverse=True)
- to_del = []
- for i in d.copy():
- if space[last_idx] - i >= 0:
- space[last_idx] -= i
- d.remove(i)
- print(last_idx, space[last_idx - 1])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement