Skip to content

Instantly share code, notes, and snippets.

Created March 10, 2015 18:43
Show Gist options
  • Save anonymous/8e24ddc8f404a5b96255 to your computer and use it in GitHub Desktop.
Save anonymous/8e24ddc8f404a5b96255 to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
string[] nums = Console.ReadLine().Split(' ');
int[] sums = new int[nums.Length / 2];
int sumsIndex = 0;
for (int i = 0; i < nums.Length - 1; i += 2)
{
sums[sumsIndex] = int.Parse(nums[i]) + int.Parse(nums[i + 1]);
sumsIndex++;
}
int diff = 0;
for (int j = 0; j < sums.Length - 1; j++)
{
if (Math.Abs(sums[j] - sums[j + 1]) > diff)
{
diff = Math.Abs(sums[j] - sums[j + 1]);
}
}
// output
if (diff == 0)
{
Console.WriteLine("Yes, value=" + sums[0]);
}
else
{
Console.WriteLine("No, maxdiff=" + diff);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment