BbJLeB

02. Half Sum Element

May 21st, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.36 KB | None | 0 0
  1. # 02. Half Sum Element
  2. import sys
  3. count = int(input())
  4. sum = 0
  5. max_num = -sys.maxsize -1
  6.  
  7. for i in range(count):
  8.     number = int(input())
  9.     sum += number
  10.     if number > max_num:
  11.         max_num = number
  12. sum -= max_num
  13.  
  14. if sum == max_num:
  15.     print(f"Yes")
  16.     print(f"Sum = {sum}")
  17. else:
  18.     print(f"No")
  19.     print(f"Diff = {abs(sum - max_num)}")
Add Comment
Please, Sign In to add comment