Kwwiker

вот подобное задание было

Jan 18th, 2021
716
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. path = '27-1b.txt'
  2. task_file = open(path)
  3.  
  4. n = int(task_file.readline())
  5.  
  6. res = 0
  7. min_razn_1 = 1000000
  8. min_razn_2 = 1000000
  9. for i in range(n):
  10.     x,y = map(int,task_file.readline().split())
  11.     res += max(x,y)
  12.     if abs(x-y) % 3 == 1:
  13.         min_razn_1 = min(min_razn_1,abs(x-y))
  14.     elif abs(x-y) % 3 == 2:
  15.         min_razn_2 = min(min_razn_2,abs(x-y))
  16.  
  17. if res % 3 != 0:
  18.     if res % 3 == 1:
  19.       res -= min_razn_1
  20.     elif res % 3 == 2:
  21.       res -= min_razn_2
  22. print(res)
RAW Paste Data