Advertisement
knikolov98

Untitled

Oct 15th, 2019
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.89 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace ConsoleApp6
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             var n = int.Parse(Console.ReadLine());
  14.             var big = int.Parse(Console.ReadLine());
  15.             var sum = big;
  16.             for (var i = 2; i <= n; i++)
  17.             {
  18.                 var a = int.Parse(Console.ReadLine());
  19.                 sum = sum + a;
  20.                 if (a > big) big = a;
  21.             }
  22.             if (big == (sum - big))
  23.             {
  24.                 Console.WriteLine("Yes");
  25.                 Console.WriteLine("Sum  = " + big);
  26.             }
  27.             else
  28.             {
  29.                 Console.WriteLine("No");
  30.                 Console.WriteLine("Diff = " + Math.Abs(big - (sum - big)));
  31.             }
  32.         }
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement