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