#K44762. Increasing Temperature Trend
Increasing Temperature Trend
Increasing Temperature Trend
Given a sequence of daily temperatures, your task is to determine whether the temperatures over a specified subarray form a non-decreasing (increasing) trend. Specifically, for a query defined by two indices \( l \) and \( r \) (1-indexed), the sequence \( T_l, T_{l+1}, \dots, T_r \) is considered to have an increasing trend if and only if for every index \( i \) such that \( l \le i < r \), the condition \( T_i \le T_{i+1} \) holds.
You will be given multiple queries. For each query, determine whether the corresponding range of temperatures meets the increasing trend criteria.
inputFormat
The input is given from stdin and has the following format:
- The first line contains two integers \( n \) and \( k \), where \( n \) is the number of days and \( k \) is the number of queries.
- The second line contains \( n \) space-separated integers representing the temperatures for each day.
- Each of the next \( k \) lines contains two integers \( l \) and \( r \) (with 1-indexing), indicating the starting and ending days of a query.
It is guaranteed that \( 1 \le l \le r \le n \).
outputFormat
For each query, output a single line to stdout containing either YES
or NO
. Print YES
if the temperature sequence in the specified range is non-decreasing, and NO
otherwise.
7 3
2 3 3 5 10 7 11
1 3
4 5
3 7
YES
YES
NO
</p>