Advertisement
Guest User

Untitled

a guest
May 22nd, 2018
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.88 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 Andrey_billiard___exercise
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13.  
  14. //int[] airArray = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();
  15. //int[] raindropsArray = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();
  16.  
  17. var airString = Console.ReadLine();
  18. var rainString = Console.ReadLine();
  19. List<int> airArray = new List<int>();
  20. List<int> raindropsArray = new List<int>();
  21. if (airString != string.Empty)
  22. {
  23. airArray = airString.Split(' ').Select(int.Parse).ToList();
  24. }
  25. if (rainString != string.Empty)
  26. {
  27. raindropsArray = rainString.Split(' ').Select(int.Parse).ToList();
  28.  
  29. }
  30.  
  31. var airArrayMax = new List<int>();
  32. var max1 = 0;
  33. var max2 = 0;
  34. var prevIndex = 0;
  35. var nextIndex = 0;
  36.  
  37. for (int i = 0; i < airArray.Count; i++)
  38. {
  39.  
  40. if (i == 0)
  41. {
  42. prevIndex = 0;
  43. nextIndex = airArray[i + 1];
  44. }
  45.  
  46. else if (i == airArray.Count - 1)
  47. {
  48. prevIndex = airArray[i - 1];
  49. nextIndex = 0;
  50. }
  51. else
  52. {
  53. prevIndex = airArray[i - 1];
  54. nextIndex = airArray[i + 1];
  55. }
  56.  
  57. if (airArray[i]> nextIndex && airArray[i]> prevIndex)
  58. {
  59. airArrayMax.Add(airArray[i]);
  60.  
  61. }
  62.  
  63. }
  64.  
  65. for (int i = 0; i < raindropsArray.Count; i++)
  66. {
  67. if(raindropsArray[i] - airArrayMax.Count > 0)
  68. {
  69. raindropsArray[i] = raindropsArray[i] - airArrayMax.Count;
  70. }
  71. }
  72.  
  73. if (airArrayMax.Count !=0)
  74. {
  75. max1 = airArrayMax.Max();
  76. }
  77. if (raindropsArray.Count !=0)
  78. {
  79. max2 = raindropsArray.Max();
  80. }
  81.  
  82. if (max1 == max2)
  83. {
  84. Console.WriteLine("Something interesting was found! ");
  85. Console.WriteLine($"Sum: {max1 + max2}");
  86. }
  87. else
  88. {
  89. Console.WriteLine("There is nothing unordinary!");
  90. Console.WriteLine($"Difference: {Math.Abs(max1 - max2)}");
  91. }
  92. }
  93. }
  94. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement