Advertisement
Korotkodul

dem23.n26

Jun 17th, 2023 (edited)
975
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.42 KB | None | 0 0
  1. f = open('26.txt')
  2. n = int(f.readline())
  3. lines = f.readlines()
  4. #print(n)
  5. #print(lines[:20])
  6. a = [int(i) for i in lines]
  7. print(type(a))
  8. #print(a[:20])
  9. a = sorted(a, reverse=1)
  10.  
  11.  
  12. print(type(a))
  13.  
  14. i = 0
  15. k = 1
  16. lst = 0
  17.  
  18. mx = a[0]
  19. while i + 1 < n:
  20.     i += 1
  21.     if abs(a[i] - a[lst]) >= 3:
  22.         #print("i = ",i)
  23.         k += 1
  24.         lst = i
  25.         mx = a[i]
  26.         #print("mx = ", mx)
  27.    
  28. print(k,mx)
  29.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement