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;
- using System.Threading.Tasks;
- namespace Andrey_billiard___exercise
- {
- class Program
- {
- static void Main(string[] args)
- {
- //int[] airArray = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();
- //int[] raindropsArray = Console.ReadLine().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(int.Parse).ToArray();
- var airString = Console.ReadLine();
- var rainString = Console.ReadLine();
- List<int> airArray = new List<int>();
- List<int> raindropsArray = new List<int>();
- if (airString != string.Empty)
- {
- airArray = airString.Split(' ').Select(int.Parse).ToList();
- }
- if (rainString != string.Empty)
- {
- raindropsArray = rainString.Split(' ').Select(int.Parse).ToList();
- }
- var airArrayMax = new List<int>();
- var max1 = 0;
- var max2 = 0;
- var prevIndex = 0;
- var nextIndex = 0;
- for (int i = 0; i < airArray.Count; i++)
- {
- if (i == 0)
- {
- prevIndex = 0;
- nextIndex = airArray[i + 1];
- }
- else if (i == airArray.Count - 1)
- {
- prevIndex = airArray[i - 1];
- nextIndex = 0;
- }
- else
- {
- prevIndex = airArray[i - 1];
- nextIndex = airArray[i + 1];
- }
- if (airArray[i]> nextIndex && airArray[i]> prevIndex)
- {
- airArrayMax.Add(airArray[i]);
- }
- }
- for (int i = 0; i < raindropsArray.Count; i++)
- {
- if(raindropsArray[i] - airArrayMax.Count > 0)
- {
- raindropsArray[i] = raindropsArray[i] - airArrayMax.Count;
- }
- }
- if (airArrayMax.Count !=0)
- {
- max1 = airArrayMax.Max();
- }
- if (raindropsArray.Count !=0)
- {
- max2 = raindropsArray.Max();
- }
- if (max1 == max2)
- {
- Console.WriteLine("Something interesting was found! ");
- Console.WriteLine($"Sum: {max1 + max2}");
- }
- else
- {
- Console.WriteLine("There is nothing unordinary!");
- Console.WriteLine($"Difference: {Math.Abs(max1 - max2)}");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement