Advertisement
Farz0l1x

Untitled

May 1st, 2024
538
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.39 KB | None | 0 0
  1. file = open('8.txt')
  2. L, N = map(int, file.readline().split())
  3. a = [0] * (L + 1)
  4. for i in range(N):
  5.     st, end = map(int, file.readline().split())
  6.     a[st] += 1
  7.     a[end] -= 1
  8. k = 0
  9. prost = 0
  10. sum_prost = 0
  11. m = 0
  12. for i in range(L):
  13.     k += a[i]
  14.     if k == 0:
  15.         prost += 1
  16.     else:
  17.         m = max(m, prost)
  18.         sum_prost += prost
  19.         prost = 0
  20. print(sum_prost, m)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement