ГлавнаяСборникиТурнирыРазделыФорумыУчастникиПечатьПомощьО системе

Разделы > Поиск > задача:


50861 - The largest Student Group

Гость
• Вопросы к жюри (4)

Задачи раздела

• 50862 - Sum of the Pairs
• 51059 - Football teams
• 51058 - Third grade students
• 51060 - Public Transportation
• 50861 - The largest Student Group
• 50815 - Breaking the Bunker
• 50483 - Group Total
• 51078 - Max trade
• 50500 - Find Student
• 50786 - Top Question
• 50788 - Eight Puzzle
• 50504 - School contest
• 51056 - Welcome Picnic

Обратная связь

Если у вас есть предложения или пожелания по работе Contester, посетите форум сайта www.contester.ru.

Лимит времени 2000/4000/4000/4000 мс. Лимит памяти 65000/65000/65000/65000 Кб.
Question by Jasmin Luka.

The largest Student Group

Your professor wants to find the group which has more excellent students. He wants the students in one group to be counted with the condition that the following student is better than the current. When the following student is worse or equal he creates another group and so on. Then he shows to the class the students of the largest group.

Question: Write a program that gets n-digits and shows the length and the numbers in reverse order of the longest sequence.

A sequence is created when numbers are in increasing order (e.g. 3, 6, 8, 15, 19, ...), then a new sequence starts when the following number is smaller or equal to its previous number in the list (e.g. 3, 6, 8, 15, 19, 4, 6, ...)
When two numbers are the same, 1st number goes to the 1st sequence and the 2nd number starts the new sequence (e.g. 8, 9, 10, 10, 15, 24, 29). First sequence includes 3 numbers (8, 9 and 10) and the second sequence includes 4 numbers (10, 15, 24 and 29).
A sequence may have just one number too (e.g. 3, 0, 1, 9); 1st sequence has just one number (3), and 2nd sequence has numbers (0, 1, 9).

Input specification:
You will be given a number n where n is between 1 and 150. Then, you will be given n integers separated by a comma.

Output specification:
Firstly show the length of the longest sequence. And then show the numbers of that sequence in reverse order. If there are several sequences with the same max length, show the elements of the first one.

Sample Input I
8
8,24,99,99,123,145,4,7
Sample Output I
3
99 24 8

Explanation:
1st Seq. (8, 24, 99) - > 3 Numbers
2nd Seq. (99, 123, 145) - > 3 Numbers
3rd Seq. (4, 7) - > 2 Numbers
1st Seq. and 2nd Seq. have both same length of numbers, so we show the length (3) and the numbers (99 24 8) of the 1st one.



Для отправки решений необходимо выполнить вход.

www.contester.ru