Rising Trend
Time limit1sMemory limit128 MB
For each test case, compute the length of the longest strictly increasing subsequence in a sequence of up to 100000 prices.
- Level
Medium4 of 10
- Topics
- Dynamic programming, Binary search, Array
- Solved
- No attempts yet
Problem
Jeongin, who enjoys stock investing, wants to study the rising trend of a stock price.
Jeongin wrote down the stock price on each of days and now wants to find a rising trend in it.
Let the prices over the days be . A rising trend is a subsequence with indices ; that is, a strictly increasing subsequence of the prices.
Given the prices over the days, write a program that finds the longest rising trend.
Input
The input consists of several test cases; read until end of input. The first line of each test case contains , the number of days on which the price was observed (). The second line contains the observed prices in order from the first day. The prices are separated by one or more spaces, and whitespace may also appear freely at other positions. Each price is a natural number no greater than 100,000.
Output
For each test case, output the length of the longest rising trend among the given prices.