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 ConsoleApplication4
- {
- class Program
- {
- static void Main(string[] args)
- {
- string inputWithSpaces = Console.ReadLine();
- int[] numbers = inputWithSpaces.Split(' ').Select(int.Parse).ToArray();
- int sum = 0;
- int counter = 0;
- int checkerArray = 0;
- int[] sums = new int[numbers.Length / 2];
- for (int i = 0; i < numbers.Length; i++)
- {
- if (i % 2 == 0)
- {
- sum += numbers[i];
- }
- if (i % 2 == 1)
- {
- sum += numbers[i];
- sums[checkerArray] = sum;
- checkerArray++;
- sum = 0;
- counter++;
- }
- }
- int x = 0;
- int checker = 0;
- int max = int.MinValue;
- int min = sums[0];
- for (int j = 0; j < counter; j++)
- {
- checker = sums[0];
- if (sums[j] > max)
- {
- max = sums[j];
- }
- if (sums[j] < min)
- {
- min = sums[j];
- }
- if (sums[j] != checker)
- {
- x = 1;
- }
- }
- int p = Math.Abs(max - min);
- if (x == 0)
- {
- Console.WriteLine("{0}{1}", "Yes, value=", checker);
- }
- if (x == 1)
- {
- Console.WriteLine("{0}{1}", "No, maxdiff=", p);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement