#K12766. Longest Non-decreasing Temperature Period

    ID: 23764 Type: Default 1000ms 256MiB

Longest Non-decreasing Temperature Period

Longest Non-decreasing Temperature Period

Sasha enjoys analyzing weather patterns and often works with temperature data. Given a series of daily temperature readings, your task is to find the longest contiguous period during which the temperature does not decrease. In other words, you need to compute the maximum length of a subarray for which every adjacent pair satisfies \(a_i \leq a_{i+1}\). This measurement helps Sasha identify sustained periods of stable or warming conditions.

Input Format: The first line contains an integer \(n\) representing the number of days. The second line contains \(n\) space-separated integers, each representing the temperature of a day.

Output Format: Output a single integer indicating the length of the longest non-decreasing period.

inputFormat

The input is read from standard input (stdin) and is structured as follows:

  • The first line contains a single integer \(n\) (the number of temperatures).
  • The second line contains \(n\) space-separated integers representing the temperature readings.

outputFormat

The output should be written to standard output (stdout) and consist of a single integer which is the maximum length of a contiguous segment where the temperatures are non-decreasing.

## sample
10
5 6 6 3 4 5 7 7 8 2
6