nq1s788

26 ячейки

Apr 15th, 2026
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.48 KB | None | 0 0
  1. data = open("27.txt").readlines()
  2. k = int(data[0])
  3. n = int(data[1])
  4. a = []
  5. for i in range(n):
  6.     l, r = map(int, data[2 + i].split())
  7.     a.append((l - 1, 0, i))
  8.     a.append((r + 1, -1, i))
  9. a.sort()
  10. c = [-1] * k
  11. answ = 0
  12. lst = -1
  13. for e in a:
  14.     time, typ, ind = e
  15.     if typ == 0:
  16.         if -1 in c:
  17.             lst = c.index(-1)
  18.             c[c.index(-1)] = ind
  19.             answ += 1
  20.     else:
  21.         if ind in c:
  22.             c[c.index(ind)] = -1
  23. print(answ, lst + 1)
Advertisement
Add Comment
Please, Sign In to add comment