Advertisement
aneliabogeva

Half Sum Element

May 20th, 2019
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. import sys
  2.  
  3. n = int(input())
  4.  
  5. max_num = -sys.maxsize -1
  6. total = 0
  7.  
  8. for i in range(0, n):
  9. num = int(input())
  10. if num > max_num:
  11. max_num = num
  12. total += num
  13.  
  14. diff = abs(max_num-total)
  15.  
  16. if diff == max_num:
  17. print(f"Yes")
  18. print(f"Sum = {max_num}")
  19. else:
  20. print(f"No")
  21. print(f"Diff = {abs(max_num - diff)}")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement