251. Longest Bitonic Subsequence
MediumDynamic Programming
A bitonic subsequence strictly increases then strictly decreases (either part may be empty). Print the length of the longest one.
Input format
Line 1: n Line 2: n integers
Output format
The length.
Example 1
Input
8 1 11 2 10 4 5 2 1
Output
6
Example 2
Input
6 12 11 40 5 3 1
Output
5
Constraints
1 ≤ n ≤ 2000
Read input from standard input and print the answer to standard output. Your code is judged against 4 test cases, most of them hidden.
Loading the MyLoginn IDE…