Advertisement
Guest User

Untitled

a guest
Jul 12th, 2018
623
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.89 KB | None | 0 0
  1. using System;
  2. class EqualPairs
  3. {
  4.     static void Main(string[] args)
  5.     {
  6.         int n = int.Parse(Console.ReadLine());
  7.         int maxDiff = 0;
  8.  
  9.         int num1 = int.Parse(Console.ReadLine());
  10.         int num2 = int.Parse(Console.ReadLine());
  11.         int previousSumValue = num1 + num2;  
  12.         for (int i = 0; i < n - 1; i++)
  13.         {
  14.             num1 = int.Parse(Console.ReadLine());
  15.             num2 = int.Parse(Console.ReadLine());
  16.             int currentSumValue = num1 + num2;
  17.             if (previousSumValue !=currentSumValue)
  18.             {
  19.                 int tempDiff = Math.Abs(previousSumValue - currentSumValue);
  20.                 maxDiff = tempDiff > maxDiff ? tempDiff : maxDiff;
  21.             }
  22.             previousSumValue = currentSumValue;
  23.         }
  24.         Console.WriteLine(maxDiff > 0 ? $"No, maxdiff={maxDiff}" : $"Yes, value={previousSumValue}");
  25.     }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement