Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Numerics;
- public class EqualPairs
- {
- static void Main()
- {
- BigInteger n = BigInteger.Parse(Console.ReadLine());
- BigInteger pairValue = 0;
- BigInteger pairMaxValue = BigInteger.Parse("-999999999999999999999999999999999999999999999");
- BigInteger pairMinValue = BigInteger.Parse("999999999999999999999999999999999999999999999");
- BigInteger pairDiff = 0;
- if (n == 0)
- {
- Console.WriteLine($"Yes, value=0"); return;
- }
- byte y = 0;
- for (BigInteger i = 1; i <= n * 2; i++)
- {
- if (y == 0) // This is the first number in pair
- {
- pairValue += BigInteger.Parse(Console.ReadLine());
- y = 1;
- continue;
- }
- if (y == 1) // This is the second number in pair
- {
- pairValue += BigInteger.Parse(Console.ReadLine());
- if (pairMinValue > pairValue)
- {
- pairMinValue = pairValue;
- }
- if (pairMaxValue < pairValue)
- {
- pairMaxValue = pairValue;
- }
- y = 0;
- pairValue = 0;
- continue;
- }
- }
- BigInteger diff = pairMaxValue - pairMinValue;
- if (diff < 0)
- {
- diff = diff * -1;
- }
- if (pairMinValue == pairMaxValue)
- {
- Console.WriteLine($"Yes, value={pairMaxValue}");
- }
- else
- {
- Console.WriteLine($"No, maxdiff={diff}");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement