Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- pairs_count = int(input())
- previous_sum = float('-inf')
- current_sum = float('inf')
- max_difference = float('-inf')
- # collects the sum of each pair
- for i in range(pairs_count):
- num1 = int(input())
- num2 = int(input())
- current_sum = num1 + num2
- if previous_sum != float('-inf'):
- abs_difference = abs(current_sum - previous_sum)
- if abs_difference > max_difference:
- max_difference = abs_difference
- previous_sum = current_sum
- # this is for the case where we only have one pair
- if pairs_count == 1:
- print(f"Yes, value={current_sum}")
- # if we have more than one pair ...
- else:
- # if the absolute max difference is 0 means that pairs are all equal and we can print any of the sum of pairs
- if max_difference == 0:
- print(f"Yes, value={current_sum}")
- # if they are not equal print the max difference
- else:
- print(f"No, maxdiff={max_difference}")
Advertisement
Add Comment
Please, Sign In to add comment