Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- pairs_count = int(input())
- min_sum = 0
- max_sum = 0
- current_sum = 0
- diff = []
- # collects the sum of each pair
- for i in range(pairs_count):
- num1 = int(input())
- num2 = int(input())
- current_sum = num1 + num2
- diff.append(current_sum)
- # initiates a variable that will hold the maximum difference between two adjacent pairs
- max_difference = float('-inf')
- # loops through the sum of pairs
- for pair in range(1, len(diff)):
- current_pair = diff[pair]
- previous_pair = diff[pair - 1]
- # calculate the difference between two adjacent pairs
- absolute_difference = abs(current_pair - previous_pair)
- # records the max difference if the absolute adjacent pairs difference is the highest so far encountered
- if absolute_difference > max_difference:
- max_difference = absolute_difference
- # this is for the case where we only have one pair
- if len(diff) == 1:
- print(f"Yes, value={diff[0]}")
- # 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={diff[0]}")
- # 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