Advertisement
ivanov_ivan

EqualPairs

Feb 14th, 2016
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.83 KB | None | 0 0
  1. int n = int.Parse(Console.ReadLine());
  2.  
  3.             int sum = int.Parse(Console.ReadLine()) + int.Parse(Console.ReadLine());
  4.             int maxDiff = 0;
  5.  
  6.             for(int i = 1; i < n; i++)
  7.             {
  8.                 int tempSum = int.Parse(Console.ReadLine()) + int.Parse(Console.ReadLine());
  9.                 int diff = Math.Abs(sum - tempSum);
  10.  
  11.                 if(sum != tempSum)
  12.                 {
  13.                     sum = tempSum;
  14.                     if(diff > maxDiff)
  15.                     {
  16.                         maxDiff = diff;
  17.  
  18.                     }
  19.                 }
  20.             }
  21.  
  22.             if(maxDiff != 0)
  23.             {
  24.                 Console.WriteLine("No, maxdiff={0}", maxDiff);
  25.             }
  26.             else
  27.             {
  28.                 Console.WriteLine("Yes, value={0}", sum);
  29.             }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement