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;
- class Program
- {
- static void Main(string[] args)
- {
- int[] numbers = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
- int l = numbers.Length;
- MaxIncSequence(numbers, l);
- }
- static void MaxIncSequence(int[] numbers, int l)
- {
- int cntCurrSeq = 0;
- int startCurrSeq = 0;
- int cntMaxSeq = 0;
- int startMaxSeq = 0;
- for (int i = 1; i < l; i++)
- {
- if (numbers[i] - numbers[i - 1] >= 1)
- {
- cntCurrSeq++;
- startCurrSeq = i - cntCurrSeq;
- if (cntCurrSeq > cntMaxSeq)
- {
- cntMaxSeq = cntCurrSeq;
- startMaxSeq = startCurrSeq;
- }
- }
- else
- {
- cntCurrSeq = 0;
- }
- }
- for (int iWrite = startMaxSeq; iWrite <= (startMaxSeq + cntMaxSeq); iWrite++)
- {
- Console.Write(numbers[iWrite] + " ");
- }
- Console.WriteLine();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement