Advertisement
Guest User

Untitled

a guest
May 22nd, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2. namespace EqualPairs
  3. {
  4.     class EqualPairs
  5.     {
  6.         static void Main(string[] args)
  7.         {
  8.             int n = Integer.parseInt(console.nextLine());
  9.             int currSum = 0;
  10.             int prevSum = 0;
  11.             int diff = 0;
  12.             int maxDiff = 0;
  13.             for (int i = 0; i < n; i++)
  14.             {
  15.                 prevSum = currSum;
  16.                 currSum = 0;
  17.                 currSum += Integer.parseInt(console.nextLine());
  18.                 currSum += Integer.parseInt(console.nextLine());
  19.                 if (i != 0)
  20.                 {
  21.                     diff = Math.Abs(currSum - prevSum);
  22.                     if (diff != 0 && diff > maxDiff)
  23.                     {
  24.                         maxDiff = diff;
  25.                     }
  26.                 }
  27.                
  28.             }
  29.             if (prevSum == currSum || n == 1)
  30.             {
  31.                  System.out.println("Yes, value={0}", currSum);
  32.             }
  33.             else
  34.             {
  35.                 System.out.println("No, maxdiff={0}", maxDiff);
  36.             }
  37.         }
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement