kolioi

Untitled

Jun 27th, 2017
372
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.85 KB | None | 0 0
  1. using System;
  2.  
  3. namespace EqualPairs
  4. {
  5.     class EqualPairs
  6.     {
  7.         static void Main(string[] args)
  8.         {            
  9.             int n = int.Parse(Console.ReadLine());
  10.  
  11.             int a = int.Parse(Console.ReadLine());
  12.             int b = int.Parse(Console.ReadLine());
  13.  
  14.             int value = a + b;
  15.  
  16.             int maxDiff = 0;
  17.  
  18.             for (int i = 1; i < n; i++)
  19.             {
  20.                 a = int.Parse(Console.ReadLine());
  21.                 b = int.Parse(Console.ReadLine());
  22.  
  23.                 if (Math.Abs(a + b - value) > maxDiff)
  24.                     maxDiff = Math.Abs(a + b - value);
  25.  
  26.                 value = a + b;
  27.             }
  28.  
  29.             if(maxDiff > 0)
  30.                 Console.WriteLine("No, maxdiff=" + maxDiff);
  31.             else
  32.                 Console.WriteLine("Yes, value=" + value);        }
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment