Advertisement
Korotkodul

dem23.n26

Jun 12th, 2023 (edited)
919
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.53 KB | None | 0 0
  1.  
  2. a = []
  3. f = open('26.txt')
  4. lines = f.readlines()
  5. f.close()
  6. #print(lines)
  7. N = int(lines[0])
  8. for i in range(1, N + 1):
  9.     a.append(int(lines[i]))
  10. a = sorted(a)
  11.  
  12. def f(i):
  13.     lst = a[i]
  14.     k = 1
  15.     for j in range(i+1, len(a)):
  16.         if a[j] - lst >= 3:
  17.             k += 1
  18.             lst = a[j]
  19.     return k
  20. v1 = (f(0), a[0])
  21. i = 0
  22. while a[i] == a[0]:
  23.     i+=1
  24. v2 = (f(i), a[i])
  25. j = i
  26. while a[j] == a[i]:
  27.     j+=1
  28. v3 = (f(j),a[j])
  29.  
  30. v = [v1, v2, v3]
  31. v = sorted(v, key = lambda x: (-x[0], -x[1]))
  32. print(v)
  33.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement