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