HomeVolumesContestsSectionsForumsUsersPrintHelpAbout

Contests > IMPC - 2013-2014 > problem:


14-01-40. 50419 - The longest bitonic sequence

IMPC - 2013-2014

Start: Mar.16.2013 at 12:00:00 PM
Finish: Mar.16.2013 at 05:00:00 PM
The contest is finished!
• Contest scoreboard

Guest
• Review clarifications (3)

Contest problems

• 50386 - Conformity
• 14-01-10. 50457 - The Number of W...
• 14-01-40. 50419 - The longest b...
• 14-01-50. 50795 - Trunk
• 14-03-10. 50412 - K numbers
• 14-03-20. 50398 - Sum of kth Anti-d...
• 14-03-30. 50377 - kth Permutation
• 14-03-40. 50773 - Balanced Sum Tree
• 14-03-60. 50382 - Parkside's Other ...
• 14-03-70. 50468 - Draw Matrix - 2
• 14-03-70. 50468 - Draw Matrix - 2

Feedback

If you notice incorrect translations in Contester, please let author know.

Time limit 2000/4000/4000/4000 ms. Memory limit 2000/64000/15000/15000 Kb.
Question by Ilir Capuni.

The longest bitonic sequence

A sequence of integers whose values first increase and reach the peek, and then decrease is called bitonic. In this problem, we are looking at bitonic sequences of a given sequence.
Note: Increasing (and decreasing) doesn't include equal to. When it's increasing, the current number is definitely greater than the previous number.

Example:
The sequence 1 2 4 6 8 7 5 4 3 2 1 is bitonic, with number 8 being the peek. A sequence of this sequence is, say 1 6 5 1, but 8 2 6 is not a sequence.

Suppose that you are given an array of integers. You need to find the length of the longest bitonic sequence of the given sequence.

Question:
Write a program that gets as an input a positive number n and a sequence of n integers and computes the length of the longest bitonic sequence.

Input specification
You will be given an integer number (n) at the beginning where 1 ≤ n ≤ 50000. Then, in the following line, you will be given n integers which are between -10000 and 10000.

Output specification
Show just one integer: length of the longest bitonic sequence.

 Sample Input I   
  6
  3 0 1 4 2 -1
 Sample Input II   
  14
  4 2 1 5 7 3 1 4 7 8 2 1 3 2
 Sample Output I   
  5
 Sample Output II   
  6

Explanation for Sample Input 2: The longest bitonic sequence is: 1 4 7 8 2 1 with the length 6.

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

www.contester.ru