Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- namespace Problem2
- {
- using System;
- using System.Collections.Generic;
- class IncreasingAbsoluteDifferences
- {
- static void Main()
- {
- int t = int.Parse(Console.ReadLine());
- for (int i = 0; i < t; i++)
- {
- string[] line = Console.ReadLine().Split(' ');
- long[] numbers = new long[line.Length];
- for (int j = 0; j < numbers.Length; j++)
- {
- numbers[j] = long.Parse(line[j]);
- }
- long[] differencesArray = new long[numbers.Length - 1];
- for (int k = 1; k < numbers.Length; k++)
- {
- long absDifference = Math.Abs(numbers[k - 1] - numbers[k]);
- differencesArray[k - 1] = absDifference;
- }
- string result = "";
- for (int x = 0; x < differencesArray.Length-1; x++)
- {
- if (differencesArray[x] > differencesArray[x + 1])
- {
- result = "False";
- break;
- }
- else
- {
- if (Math.Abs(differencesArray[x] - differencesArray[x+1]) > 1)
- {
- result = "False";
- break;
- }
- else
- {
- result = "True";
- }
- }
- }
- Console.WriteLine(result);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement