The Mountain Subsequence
A bitonic subsequence strictly increases and then strictly decreases (either side may be length 1). Print the length of the longest bitonic subsequence.
Input: the first line has N; the second line has N integers.
Output: the longest bitonic subsequence length.
Constraints:
- 1 ≤ N ≤ 5000 (tests use N ≤ 1500)
- |ai| ≤ 109
Sample Tests
Input 1
7 1 4 2 3 5 4 1
Output 1
6
Input 2
1 9
Output 2
1
Discussion (opens after you solve — no spoilers before)
No comments yet.