The 2-Day High
Halcyon's screen carries a two-day high beside each price: the better of today's close and yesterday's. The desk reads it as a very short memory — if today sits below the two-day high then yesterday was the better day to have sold. The window is exactly two days wide and never wider, so a high from three days ago has already dropped out of it.
Task: Print the two-day high for every day that has a day before it.
Input
The first line holds an integer n, always at least 2. Each of the next n lines holds one day's closing price.
Output
One line for every day after the first — n - 1 lines in all — with exactly one digit after the decimal point. Each line is the higher of that day and the day immediately before it. The opening day produces no line.
Example:
Input:
5
3
1
4
1
5
Output:
3.0
4.0
4.0
5.0
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