Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace HalfSumElement
- {
- class Program
- {
- static void Main(string[] args)
- {
- int n = int.Parse(Console.ReadLine());
- int sum = 0;
- int max = int.MinValue;
- for (int i = 0; i < n; i++)
- {
- int num = int.Parse(Console.ReadLine());
- sum += num;
- if (num > max)
- {
- max = num;
- }
- }
- int result = sum - max;
- if (max == result)
- {
- Console.WriteLine("Yes");
- Console.WriteLine($"Sum = {max}");
- }
- else
- {
- Console.WriteLine("No");
- Console.WriteLine($"Diff = {Math.Abs(max - result)}");
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment