The Longest Rally
Halcyon Capital's desk notes the longest unbroken rally a share has managed, because a long clean run is what the sales team puts in a pitch. A rally is broken by any day that fails to close above the day before it, and a day that closes exactly level counts as broken rather than as a continuation.
Task: Print the length of the longest rally, in days.
Input
The first line holds an integer n, the number of days. Each of the next n lines holds one day's closing price.
Output
One line: a whole number counting the days in the rally, not the steps between them, so prices of 2, 5, 9 make a rally of three. Every series contains at least one day, so the smallest possible answer is 1, which is what a series that never rises prints.
Example:
Input:
7
1
2
3
2
3
4
5
Output:
4
Sign in to solve this problem
Reading problems is free for everyone — solving them (Run, Submit, and tracking what you've solved) needs an account.
Sign in