Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class HalfSumElement
- {
- static void Main()
- {
- int n = int.Parse(Console.ReadLine());
- int sum = 0;
- int max = Int32.MinValue;
- for (int i = 0; i < n; i++)
- {
- int num = int.Parse(Console.ReadLine());
- sum += num;
- max = Math.Max(max, num);
- }
- int clearSum = sum - max;
- if (clearSum == max)
- {
- Console.WriteLine("Yes sum = {0}", clearSum);
- }
- else
- {
- Console.WriteLine("No, diff = {0}", Math.Abs(clearSum - max));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement