#K43872. Melody Checker
Melody Checker
Melody Checker
You are given a sequence of n integers representing the notes produced by a musical keyboard. Your task is to determine whether the sequence forms a strictly increasing melody, strictly decreasing melody, or neither.
A melody is defined as follows:
- The melody is up if for all \(0 \leq i < n-1\), \(a_i < a_{i+1}\).
- The melody is down if for all \(0 \leq i a_{i+1}\).
- Otherwise, the melody is classified as neither.
For example, given the notes [3, 6, 9, 12, 15], the melody is strictly increasing, so the answer is "UP". If the notes are [10, 8, 6, 2], then the answer is "DOWN". In any other case, output "NEITHER".
inputFormat
The input is read from stdin and consists of two lines:
- The first line contains an integer \(n\) that denotes the number of notes.
- The second line contains \(n\) space-separated integers representing the notes.
outputFormat
Output a single line to stdout containing one of the strings: "UP", "DOWN", or "NEITHER", based on the given melody.
## sample5
3 6 9 12 15
UP