Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- public class Program
- {
- public static void Main(string[] args)
- {
- List<int> airArray = Console.ReadLine().Split(new[] {' '}, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse)
- .ToList();
- List<int> rainDropArray = Console.ReadLine().Split(new[] {' '}, StringSplitOptions.RemoveEmptyEntries)
- .Select(int.Parse).ToList();
- List<int> AirArrayMaxes = new List<int>();
- if (airArray != null)
- for (int i = 0; i < airArray.Count; i++)
- {
- int startOfArray = i - 1;
- int left = startOfArray >= 0 ? airArray[startOfArray] : default(int);
- int central = airArray[i];
- int endOfArray = i + 1;
- int right = endOfArray <= airArray.Count - 1 ? airArray[i + 1] : default(int);
- bool localMax = left < central && central > right;
- if (localMax)
- {
- AirArrayMaxes.Add(central);
- }
- }
- int lowerwith = AirArrayMaxes.Count;
- List<int> ModifiedRainArray = new List<int>();
- if (rainDropArray != null)
- for (int j = 0; j < rainDropArray.Count; j++)
- {
- rainDropArray[j] -= lowerwith;
- if (rainDropArray[j] < 0)
- {
- rainDropArray[j] = 0;
- }
- ModifiedRainArray.Add(rainDropArray[j]);
- }
- int airMax =AirArrayMaxes.Any()?AirArrayMaxes.Max():0;
- int rainMax = ModifiedRainArray.Any() ?ModifiedRainArray.Max():0;
- //int airMax = AirArrayMaxes.GroupBy(x => airfirst).Any(g => g.Any()) ? airfirst : 0;
- //int rainMax = ModifiedRainArray.GroupBy(x => rainfirst).Any(g => g.Any()) ? rainfirst : 0;
- if (airMax == rainMax)
- {
- Console.WriteLine("Something interesting was found!" + Environment.NewLine
- + "Sum: {0}", airMax + rainMax);
- }
- else
- {
- Console.WriteLine("There is nothing unordinary! " + Environment.NewLine +
- "Difference: {0}", Math.Abs(airMax - rainMax));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement