fork download
  1. import sys
  2. input = sys.stdin.readline
  3. n,k = map(int,input().split())
  4. # l = [0]*n
  5. start = [0]*n
  6. end = [0]*n
  7. for _ in range(k):
  8. a,b = map(int,input().split())
  9. a -= 1
  10. b -= 1
  11. start[a] += 1
  12. end[b] += 1
  13.  
  14. balance = 0
  15. ans = []
  16. for i in range(n):
  17. e1 = start[i]
  18. e2 = end[i]
  19. total = 0
  20. if e1 >= e2:
  21. total += e1
  22. total += balance
  23. balance += (e1-e2)
  24.  
  25. else:
  26. total += e1
  27. total += balance
  28. balance -= (e2-e1)
  29.  
  30. ans.append(total)
  31.  
  32. ans.sort()
  33. # if n%2 == 1:
  34. sys.stdout.write(str(ans[n//2])+"\n")
Runtime error #stdin #stdout #stderr 0.14s 23440KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Traceback (most recent call last):
  File "./prog.py", line 3, in <module>
ValueError: not enough values to unpack (expected 2, got 0)