Untitled

 avatar
unknown
plain_text
a year ago
1.6 kB
6
Indexable
using System;

namespace _08.EqualPairs
{
    internal class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int a = 0;
            int b = 0;
            int c = 0;
            int d = 0;
            int maxValue = int.MinValue;
            int minValue = int.MaxValue;
            int groupA = 0;
            int groupB = 0;


            for (int i = 1; i <= n; i++)
            {
                if (i % 2 == 0)
                {
                    c = int.Parse(Console.ReadLine());
                    d = int.Parse(Console.ReadLine());
                    groupA = c + d;
                    if (groupA > maxValue) { maxValue = groupA; }
                    if (groupA < minValue) { minValue = groupA; }
                }
                else 
                {
                    a = int.Parse(Console.ReadLine());
                    b = int.Parse(Console.ReadLine());
                    groupB = a + b;
                    if (groupB > maxValue) { maxValue = groupB; }
                    if (groupB < minValue) { minValue = groupB; }
                }
                
            }
            if (n == 1 && c == d) { Console.WriteLine($"Yes, value={groupB}"); }
            else if (n==1 && c !=d) { Console.WriteLine($"No, maxdiff={Math.Abs(c-d)}"); }
            else if (groupA == groupB) { Console.WriteLine($"Yes, value={groupB}"); }
            else { Console.WriteLine($"No, maxdiff={Math.Abs(groupA-groupB)}"); }
        }
    }
}
Editor is loading...
Leave a Comment