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 _2.Pairs
- {
- class Program
- {
- static void Main(string[] args)
- {
- int[] array = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
- List<int> sum = new List<int>();
- int currSum = array[0] + array[1];
- if (array.Length == 2 && array[0]==array[1])
- {
- Console.WriteLine("Yes, value={0}", currSum);
- return;
- }
- int nextsum = 0;
- bool areEqual = false;
- bool maxDifference = false;
- int diff = 0;
- int maxDiff = int.MinValue;
- sum.Add(currSum);
- for (int i = 2; i < array.Length; i++)
- {
- nextsum = array[i] + array[i + 1];
- sum.Add(nextsum);
- if (currSum == nextsum)
- {
- areEqual = true;
- }
- i++;
- }
- if (areEqual)
- {
- Console.WriteLine("Yes, value={0}", nextsum);
- return;
- }
- for (int i = 0; i < sum.Count-1; i++)
- {
- diff = Math.Abs(sum[i] - sum[i+1]);
- if (diff > maxDiff)
- {
- maxDiff = diff;
- maxDifference = true;
- }
- }
- if (maxDifference)
- {
- Console.WriteLine("No, maxdiff={0}", maxDiff);
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment