Advertisement
maxim_shlyahtin

17

Nov 16th, 2021
652
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.94 KB | None | 0 0
  1. f, count, max_sum = [], 0, -(10 ** 10)
  2. i = int(input())
  3. f.append(i)
  4. while i != 0:
  5.     i = int(input())
  6.     f.append(i)
  7. f.pop(len(f) - 1)
  8. for i in range(len(f) - 2):
  9.     if i - 1 >= 0 and i + 1 <= len(f) - 1:
  10.         if f[i] % 10 == 9 and f[i] > 0 and (f[i + 1] % 10 != 9 or f[i + 1] <= 0) and (f[i - 1] % 10 != 9 or f[i - 1] <= 0):
  11.             count += 1
  12.             if max_sum < f[i - 1] + f[i] + f[i + 1]:
  13.                 max_sum = f[i - 1] + f[i] + f[i + 1]
  14. print(count, max_sum)
  15.  
  16. i = int(input())
  17. f.append(i)
  18. count, min_ras = 0, 10 ** 10
  19. f.append(i)
  20. while i != 0:
  21.     i = int(input())
  22.     f.append(i)
  23. f.pop(len(f) - 1)
  24. for i in range(1, len(f) - 1):
  25.     if f[i - 1] < f[i] and f[i] < f[i + 1] and i + 1 < len(f):
  26.         count += 1
  27.         if (max(f[i - 1], f[i], f[i + 1]) - min(f[i - 1], f[i], f[i + 1])) < min_ras:
  28.             min_ras = max(f[i - 1], f[i], f[i + 1]) - min(f[i - 1], f[i], f[i + 1])
  29. print(count)
  30. print(min_ras)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement