Advertisement
Farz0l1x

Untitled

May 1st, 2024
433
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.44 KB | None | 0 0
  1. file = open('1.txt')
  2. K = int(file.readline())
  3. N = int(file.readline())
  4. a = []
  5. for i in range(N):
  6.     st, end = map(int, file.readline().split())
  7.     a.append((st, end))
  8. a.sort()
  9. camera = [0] * K
  10. count = 0
  11. last_camera = 0
  12. for i in range(N):
  13.     st, end = a[i]
  14.     for j in range(K):
  15.         if camera[j] < st:
  16.             camera[j] = end
  17.             count += 1
  18.             last_camera = j + 1
  19.             break
  20. print(count, last_camera)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement