Sichanov

ss

Feb 2nd, 2021
151
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.56 KB | None | 0 0
  1. num_pairs = int(input())
  2. max_diff = 0
  3. current_sum = 0
  4. sum_first_pair = 0
  5. diff = 0
  6. for i in range(1, 2 * num_pairs + 1):
  7.     number = int(input())
  8.     current_sum += number
  9.     if i % 2 == 0 and i != 2:
  10.         diff = abs(current_sum - sum_first_pair)
  11.         if diff > max_diff:
  12.             max_diff = diff
  13.         sum_first_pair = current_sum
  14.         current_sum = 0
  15.     elif i == 2:
  16.         sum_first_pair = current_sum
  17.         current_sum = 0
  18.  
  19. if max_diff == 0:
  20.     print(f'Yes, value={sum_first_pair}')
  21. else:
  22.     print(f'No, maxdiff={max_diff}')
Advertisement
Add Comment
Please, Sign In to add comment