#K1961. Cresting Students
Cresting Students
Cresting Students
You are given a list of integers representing the heights of students standing in a line. A student is called cresting if their height is greater than both of their immediate neighbors. Formally, for a student at index i (using 1-indexing), it is cresting if
\( \text{height}_i > \text{height}_{i-1} \) and \( \text{height}_i > \text{height}_{i+1} \),
with the restriction that the first and last students (i.e. indices 1 and n) are not considered since they do not have two neighbors.
Your task is to identify the cresting students and output their indices (using 1-indexing) separated by a space. If there are no cresting students, output NONE
.
inputFormat
The input is read from stdin and consists of two lines:
- The first line contains a single integer n representing the number of students.
- The second line contains n space-separated integers representing the heights of the students in order.
outputFormat
Output to stdout the 1-indexed positions of the cresting students separated by a single space. If no student is cresting, output the string NONE
.
5
1 3 2 5 4
2 4