Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- k = int(input())
- n = int(input())
- people = {}
- for _ in range(n):
- start, duration = map(int, input().split())
- people[start] = people.get(start, []) + [start + duration + 1]
- time_stop = count = 0
- box = [0] * k
- box_2 = [0] * k
- for time in range(max(people.keys()) + 1):
- box = [(0 if i == time else i) for i in box]
- box_2 = [(0 if i == time else i) for i in box_2]
- if 0 not in box_2:
- time_stop += 1
- for end in sorted(people.get(time, [])):
- if 0 in box:
- i = box.index(0)
- box[i] = end
- box_2[i] = end - 1
- else:
- count += 1
- # print(time, box)
- print(count, time_stop)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement