eolymp
bolt
Try our new interface for solving problems
Problems

Stock Exchange

Stock Exchange

The world financial crisis is quite a subject. Some people are more relaxed while others are quite anxious. John is one of them. He is very concerned about the evolution of the stock exchange. He follows stock prices every day looking for rising trends. Given a sequence of numbers $p_1, p_2, ..., p_n$ representing stock prices, a rising trend is a subsequence $p_{i_1} < p_{i_2} < ... < p_{i_k}$ with $i_1 < i_2 < ... < i_k$. John's problem is to find very quickly the longest rising trend. \InputFile Each data set stands for a particular set of stock prices. A data set starts with the length $L~(L \le 10^5)$ of the sequence of numbers, followed by integers. White spaces can occur freely in the input. The input data are correct and terminate with an end of file. \OutputFile Print the length of the longest rising trend. For each data set print the answer from the new line. \Examples There are three data sets. In the first case, the length $L$ of the sequence is $6$. The sequence is $5, 2, 1, 4, 5, 3$. The length of the longest rising trend is $3$.
Time limit 1 second
Memory limit 128 MiB
Input example #1
6
5 2 1 4 5 3

3
1 1 1

4
4 3 2 1
Output example #1
3
1
1