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 EqualPairs
- {
- class Program
- {
- static void Main(string[] args)
- {
- var n = int.Parse(Console.ReadLine());
- int currentSum = 0;
- int previousSum = 0;
- int difference = 0;
- int maxdifference = 0;
- for (int i = 1; i <= n; i++)
- {
- var num1 = int.Parse(Console.ReadLine());
- var num2 = int.Parse(Console.ReadLine());
- currentSum = num1 + num2;
- if (i > 1) // za vsqka dvoika bez pyrvata presmqtaite razlikata s predhodnata:
- {
- difference = Math.Abs(previousSum - currentSum);
- if (difference > maxdifference)
- {
- maxdifference = difference; // namirame nai-golqmata razlika
- }
- }
- previousSum = currentSum;
- }
- if (maxdifference == 0) // ako razlikata e 0 znachi vsichki sumi sa ednakvi
- {
- Console.WriteLine("Yes, value={0}", previousSum);
- }
- else
- {
- Console.WriteLine("No, maxdiff={0}", maxdifference);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment