Advertisement
ALEXANDAR_GEORGIEV

equal_pairs

Jun 9th, 2022
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.70 KB | None | 0 0
  1. count_pair = int(input())
  2. check_count = 2 * count_pair
  3. pair = 0
  4. a = 0
  5. list_pair = []
  6. while check_count:
  7.     num = int(input())
  8.     pair = pair + num
  9.     a = a + 1
  10.     if a == 2:
  11.         list_pair.append(pair)
  12.         pair = 0
  13.         a = 0
  14.  
  15.     check_count -= 1
  16.  
  17. equ = True
  18. first_num = list_pair[0]
  19. for number in list_pair:
  20.     if number != first_num:
  21.         equ = False
  22.         break
  23.  
  24. max_diff = 0
  25. for x in range(len(list_pair)):
  26.     for y in range(x + 1, len(list_pair)):
  27.         if (abs(list_pair[x] - list_pair[y])) > max_diff:
  28.             max_diff = abs(list_pair[x] - list_pair[y])
  29.  
  30. if equ:
  31.     print(f'Yes, value={list_pair[0]}')
  32. else:
  33.     print(f'No, maxdiff={max_diff}')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement