| Author: | Pavel Mesenev | Time limit: | 2 sec | |
| Input file: | Standard input | Memory limit: | 256 Mb | |
| Output file: | Standard output |
You are given an array a0, a1, …, an − 1 of integers. For every index i, find the first index j > i with aj > ai, and report aj. If no such j exists, report − 1.
The first line contains one integer n. The second line contains n space-separated integers a0… an − 1.
Print n space-separated integers: the answer for each index, in order.
1 ≤ n ≤ 2 ⋅ 105
1 ≤ ai ≤ 109
| No. | Standard input | Standard output |
|---|---|---|
| 1 |
|
|
| 2 |
|
|
| 3 |
|
|