Advertisement
Guest User

Untitled

a guest
May 27th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. n = int(input())
  2. s = 0
  3. min_dif = 10001
  4. for i in range(n):
  5. a, b, c = map(int, input().split())
  6. if a > b :
  7. t = a
  8. a = b
  9. b = t
  10. if b > c:
  11. t = b
  12. b = c
  13. c = t
  14. if a > b:
  15. t = a
  16. a = b
  17. b = t
  18. # до этого момента мы упорядочиваем числа по возрастанию, так удобнее с ними работать
  19. s += a # добавляем в сумму минимальное
  20. if b - a < min_dif and (b - a) % 5 != 0:
  21. min_dif = b - a
  22. if c - a < min_dif and (c - a) % 5 != 0:
  23. min_dif = c - a
  24. # тут мы считали минимальную разницу
  25. if s % 5 == 0:
  26. if min_dif == 10001:
  27. s = 0
  28. else :
  29. s += min_dif
  30. print(s)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement