Problems > Suffix Minima

Suffix Minima

Difficulty: 900 3500 ms 128 MB

implementation

For every position print the minimum of ai..N.

Input: the first line has N; the second line has N integers.

Output: N integers: the minimum from each position to the end.

Constraints:

  • 1 ≤ N ≤ 105
  • -10000 ≤ ai ≤ 10000

Sample Tests

Input 1
4
2 1 5 3
Output 1
1 1 3 3
Input 2
1
9
Output 2
9

Read the Editorial

Discussion (opens after you solve — no spoilers before)

No comments yet.

Submit Your Solution

Log in or create a free account to run and submit code.