#K41797. Detect Increasing Plant Height Period
Detect Increasing Plant Height Period
Detect Increasing Plant Height Period
You are given several datasets representing the height measurements of plants over a series of days. For each dataset, the first number indicates the number of days, followed by the height readings for each day. Your task is to determine whether there exists any consecutive pair of days where the plant's height strictly increases.
If at least one consecutive pair of days satisfies \(h_i < h_{i+1}\), output YES
for that dataset; otherwise, output NO
. Note that for a dataset with only one day, the answer should be NO
because there is no pair to compare.
The input contains multiple datasets and is terminated by a line with a zero, which should not be processed.
inputFormat
The input is read from standard input (stdin) and consists of several datasets. Each dataset is provided in two consecutive lines:
- The first line of a dataset contains a single integer \(n\) (\(n \ge 0\)) representing the number of days. A line with
0
indicates the end of input and should not be processed. - If \(n > 0\), the second line contains \(n\) space-separated integers representing the height measurements for each day.
outputFormat
For each dataset (except the terminating case), output a single line to standard output (stdout) containing either YES
or NO
depending on whether there exists a consecutive pair of days with a strictly increasing height.
5
1 2 3 4 5
4
5 4 3 2
0
YES
NO
</p>