Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace _10_Half_Sum_Element
- {
- class Program
- {
- static void Main(string[] args)
- {
- int n = int.Parse(Console.ReadLine());
- int sum = 0;
- int maxN = 0;
- for (int i = 0; i < n; i++)
- {
- int number = int.Parse(Console.ReadLine());
- maxN = Math.Max(number, maxN);
- sum = number + sum;
- }
- if (sum - maxN == maxN)
- {
- Console.WriteLine("Yes");
- Console.WriteLine("Sum = {0}", sum / 2);
- }
- else
- {
- Console.WriteLine("No");
- Console.WriteLine("Diff = {0}", Math.Abs(maxN - (sum - maxN)));
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment