#P5788. 【模板】单调栈
【模板】单调栈
Description
Given an integer sequence with terms.
Define a function as the index of the first element after the -th element in the sequence that is greater than , that is, . If it does not exist, then .
Find .
Input Format
The first line contains a positive integer .
The second line contains positive integers .
Output Format
Output one line with integers representing the values of .
5
1 4 2 3 5
2 5 4 5 0
Hint
Constraints
For of the testdata, .
For of the testdata, .
For of the testdata, , .
Translated by ChatGPT 5
京公网安备 11011102002149号