Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class Pairs
- {
- static void Main()
- {
- string input = Console.ReadLine();
- int counter = 0;
- string firstInteger = "";
- string secondInteger = "";
- int maxDiff = 0;
- int? sum1 = null;
- int? sum2 = null;
- while(counter<input.Length)
- {
- firstInteger = "";
- secondInteger = "";
- while (input[counter]!=' ')
- {
- firstInteger = firstInteger + input[counter];
- counter++;
- }
- counter++;
- while (counter<input.Length && input[counter]!=' ')
- {
- secondInteger = secondInteger + input[counter];
- counter++;
- }
- counter++;
- sum2 = int.Parse(secondInteger) + int.Parse(firstInteger);
- if (sum1!=null)
- {
- maxDiff = Math.Max(maxDiff,Math.Abs((int)sum2 - (int)sum1));
- }
- sum1 = sum2;
- }
- if (maxDiff==0)
- {
- Console.WriteLine("Yes, value={0}",sum2);
- }
- else
- {
- Console.WriteLine("No, maxdiff={0}",maxDiff);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement