Advertisement
Guest User

Untitled

a guest
Feb 16th, 2016
265
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace HalfSumElement
  7. {
  8. class Program
  9. {
  10. static void Main(string[] args)
  11. {
  12. var n = int.Parse(Console.ReadLine());
  13. var sum = 0.0;
  14. var maxNum = -100000000;
  15.  
  16. for (int i = 0; i < n; i++)
  17. {
  18. var y = int.Parse(Console.ReadLine());
  19. sum += y;
  20.  
  21. if (y > maxNum)
  22. {
  23. maxNum = y;
  24. }
  25.  
  26. }
  27.  
  28. var sumSmaller = (sum - maxNum);
  29.  
  30. if ((sumSmaller) == maxNum)
  31. {
  32. Console.WriteLine("Yes sum " + maxNum);
  33. }
  34. else
  35. {
  36. Console.WriteLine("No diff " + Math.Abs(maxNum - sumSmaller));
  37. }
  38.  
  39. }
  40. }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement