Advertisement
wrequiems

Untitled

Mar 18th, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.38 KB | None | 0 0
  1. def go():
  2.     n = int(input())
  3.     a = [int(i) for i in input().split(' ')]
  4.     a.sort()
  5.     m = start = end = 0
  6.     while end < n:
  7.         while end < n and a[end] - a[start] <= 5:
  8.             end += 1
  9.         m = max(m, end - start)
  10.         while start < n - 1 and a[start] == a[start + 1]:
  11.             start += 1
  12.         start += 1
  13.     return max(m, end - start)
  14.  
  15. print(go())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement