Advertisement
kaloyanTr

EqualPairs

Feb 25th, 2016
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace EqualPairs
  8. {
  9. class equalPairs
  10. {
  11. static void Main(string[] args)
  12. {
  13. int n = int.Parse(Console.ReadLine());
  14. int currentSum = 0, prevSum = 0, diff = 0, bigDiff = 0;
  15.  
  16. for (int i = 0; i < n; i++)
  17. {
  18. int firstNum = int.Parse(Console.ReadLine());
  19. int secondNum = int.Parse(Console.ReadLine());
  20.  
  21. if (i == 0)
  22. {
  23. prevSum = firstNum + secondNum;
  24. }
  25. else
  26. {
  27. currentSum = firstNum + secondNum;
  28. diff = Math.Abs(currentSum - prevSum);
  29. if (bigDiff < diff) bigDiff = diff;
  30.  
  31. prevSum = currentSum;
  32. }
  33. }
  34. if (bigDiff == 0) Console.WriteLine("Yes, value = " + prevSum);
  35. else Console.WriteLine("No, maxdiff = " + bigDiff);
  36. }
  37. }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement