Advertisement
Aliendreamer

underwaters softuni still underwork halfway on

May 22nd, 2018
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.40 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6.      public  class Program
  7.     {
  8.         public static void Main(string[] args)
  9.         {
  10.            
  11.         List<int> airArray = Console.ReadLine().Split(new[] {' '}, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse)
  12.             .ToList();
  13.         List<int> rainDropArray = Console.ReadLine().Split(new[] {' '}, StringSplitOptions.RemoveEmptyEntries)
  14.             .Select(int.Parse).ToList();
  15.  
  16.      
  17.         List<int> AirArrayMaxes = new List<int>();
  18.  
  19.             if (airArray != null)
  20.             for (int i = 0; i < airArray.Count; i++)
  21.             {
  22.                 int startOfArray = i - 1;
  23.                 int left = startOfArray >= 0 ? airArray[startOfArray] : default(int);
  24.                 int central = airArray[i];
  25.                 int endOfArray = i + 1;
  26.                 int right = endOfArray <= airArray.Count - 1 ? airArray[i + 1] : default(int);
  27.  
  28.                 bool localMax = left < central && central > right;
  29.  
  30.                 if (localMax)
  31.                 {
  32.                     AirArrayMaxes.Add(central);
  33.                 }
  34.             }
  35.  
  36.         int lowerwith = AirArrayMaxes.Count;
  37.         List<int> ModifiedRainArray = new List<int>();
  38.  
  39.             if (rainDropArray != null)
  40.             for (int j = 0; j < rainDropArray.Count; j++)
  41.             {
  42.                 rainDropArray[j] -= lowerwith;
  43.                 if (rainDropArray[j] < 0)
  44.                 {
  45.                     rainDropArray[j] = 0;
  46.                 }
  47.  
  48.                 ModifiedRainArray.Add(rainDropArray[j]);
  49.             }
  50.  
  51.  
  52.         int airMax =AirArrayMaxes.Any()?AirArrayMaxes.Max():0;
  53.      
  54.         int rainMax = ModifiedRainArray.Any() ?ModifiedRainArray.Max():0;
  55.  
  56.  
  57.         //int airMax = AirArrayMaxes.GroupBy(x => airfirst).Any(g => g.Any()) ? airfirst : 0;
  58.         //int rainMax = ModifiedRainArray.GroupBy(x => rainfirst).Any(g => g.Any()) ? rainfirst : 0;
  59.  
  60.         if (airMax == rainMax)
  61.         {
  62.             Console.WriteLine("Something interesting was found!" + Environment.NewLine
  63.                                                                  + "Sum: {0}", airMax + rainMax);
  64.  
  65.         }
  66.         else
  67.         {
  68.             Console.WriteLine("There is nothing unordinary! " + Environment.NewLine +
  69.                               "Difference: {0}", Math.Abs(airMax - rainMax));
  70.  
  71.         }
  72.         }
  73.              
  74.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement