Advertisement
gruslan

t8168

Jun 18th, 2023
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.68 KB | None | 0 0
  1. k = int(input())
  2. n = int(input())
  3.  
  4. people = {}
  5. for _ in range(n):
  6.     start, duration = map(int, input().split())
  7.     people[start] = people.get(start, []) + [start + duration + 1]
  8.  
  9. time_stop = count = 0
  10.  
  11. box = [0] * k
  12. box_2 = [0] * k
  13. for time in range(max(people.keys()) + 1):
  14.     box = [(0 if i == time else i) for i in box]
  15.     box_2 = [(0 if i == time else i) for i in box_2]
  16.  
  17.     if 0 not in box_2:
  18.         time_stop += 1
  19.  
  20.     for end in sorted(people.get(time, [])):
  21.         if 0 in box:
  22.             i = box.index(0)
  23.             box[i] = end
  24.             box_2[i] = end - 1
  25.         else:
  26.             count += 1
  27.     # print(time, box)
  28.  
  29. print(count, time_stop)
  30.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement