Advertisement
Guest User

Untitled

a guest
Feb 24th, 2016
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.30 KB | None | 0 0
  1. namespace Couples
  2. {
  3. using System;
  4.  
  5. using static System.Console;
  6.  
  7. class Program
  8. {
  9. private static void Main(string[] args)
  10. {
  11. int n = int.Parse(ReadLine());
  12.  
  13. double a = double.Parse(ReadLine());
  14. double b = double.Parse(ReadLine());
  15.  
  16. double value = a + b;
  17. double maxDiff = double.MinValue;
  18. bool areEqual = true;
  19. double previousValue = value;
  20.  
  21. for (int i = 0; i < n - 1; i++)
  22. {
  23. a = double.Parse(ReadLine());
  24. b = double.Parse(ReadLine());
  25. double currentValue = a + b;
  26.  
  27. if (areEqual && Math.Abs((a + b) - value) > 0.0001)
  28. {
  29. areEqual = false;
  30. }
  31.  
  32. double currentDiff = Math.Abs(currentValue - previousValue);
  33. if (currentDiff - maxDiff > 0.0001)
  34. {
  35. maxDiff = currentDiff;
  36. }
  37.  
  38. previousValue = currentValue;
  39. }
  40.  
  41. if (areEqual)
  42. {
  43. WriteLine($"Yes, value={value}");
  44. }
  45. else
  46. {
  47. WriteLine($"No, maxdiff={maxDiff}");
  48. }
  49. }
  50. }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement