kkorionkk

Task #27

Jun 10th, 2021
652
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # набор из троек, каждое не делится на 9 и должно быть минимально
  2. f = open("27b.txt")
  3. n = int(f.readline())
  4. summ = 0
  5. min_razn = 1000000
  6. for i in range(n):
  7.     n_1, n_2, n_3 = map(int, f.readline().split())
  8.     a = [n_1, n_2, n_3]
  9.     a.sort()
  10.     summ = summ + a[0] + a[1]
  11.     if (a[2] - a[0]) < min_razn and (a[2] - a[0])%9 != 0:
  12.         min_razn = a[2] - a[0]
  13.     if (a[2] - a[1]) < min_razn and (a[2] - a[1])%9 != 0:
  14.         min_razn = a[2] - a[1]
  15. if summ%9==0:
  16.     print(summ+min_razn)
RAW Paste Data