Sichanov

equal pairs

Jul 10th, 2021
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.53 KB | None | 0 0
  1. n = int(input())
  2. pair1 = 0
  3. pair2 = 0
  4. max_diff = 0
  5. is_equal = False
  6. for i in range(1, 2*n + 1):
  7.     number = int(input())
  8.     if i <= 2:
  9.         pair1 += number
  10.     else:
  11.         pair2 += number
  12.         if i % 2 == 0:
  13.             if pair2 == pair1:
  14.                 is_equal = True
  15.             else:
  16.                 is_equal = False
  17.             max_diff = abs(pair1 - pair2)
  18.             pair1 = pair2
  19.             pair2 = 0
  20. if max_diff == 0:
  21.     print(f'Yes, value={pair1}')
  22. else:
  23.     print(f'No, maxdiff={max_diff}')
  24.  
  25.  
Advertisement
Add Comment
Please, Sign In to add comment