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 _12_Equal_Pairs
- {
- class Program
- {
- static void Main(string[] args)
- {
- var n = int.Parse(Console.ReadLine());
- var sum = 0;
- var sumPrev = 0;
- var diff = 0;
- var diffMax = 0;
- for (var i = 1; i <= n; i++)
- {
- sumPrev = sum;
- var numOne = int.Parse(Console.ReadLine());
- var numTwo = int.Parse(Console.ReadLine());
- sum = numOne + numTwo;
- }
- for (var j = 2; j <= n; j++)
- {
- diff = Math.Abs(sum - sumPrev);
- if (diff > diffMax)
- {
- diffMax = diffMax + diff;
- }
- }
- if (diffMax == 0)
- {
- Console.WriteLine("Yes, value ={0}", sum);
- }
- else
- {
- Console.WriteLine("No, maxdiff ={0}", diffMax);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement