Prefix Maxima
For every position print the maximum of the first i elements.
Input: the first line has N; the second line has N integers.
Output: N integers: the running maximum at each position.
Constraints:
- 1 ≤ N ≤ 105
- -10000 ≤ ai ≤ 10000
Sample Tests
Input 1
4 2 1 5 3
Output 1
2 2 5 5
Input 2
1 -7
Output 2
-7
Discussion (opens after you solve — no spoilers before)
No comments yet.