#K6321. Longest Sales Streak Analysis

    ID: 31703 Type: Default 1000ms 256MiB

Longest Sales Streak Analysis

Longest Sales Streak Analysis

A company closely monitors the daily sales data for each of its products. For every product, you are provided with the number of days followed by the sales numbers for each day. Your task is to determine the length of the longest consecutive streak where the sales values are strictly increasing or strictly decreasing.

Formally, for a sequence of sales values \(a_1, a_2, \dots, a_m\), a streak is defined as a maximal consecutive subsequence where either \(a_{i} < a_{i+1}\) for all valid \(i\) or \(a_{i} > a_{i+1}\) for all valid \(i\). If the value remains the same, the streak breaks and restarts. You are required to compute such longest streak for each product.

Input/Output: The input is taken from standard input (stdin) and the result should be printed to standard output (stdout). For each product, output the maximum streak length. Multiple results must be printed on a single line, separated by a space.

inputFormat

The first line contains a single integer \(n\), representing the number of products. This is followed by \(n\) sets of data. For each product:

  • The first number is an integer \(m\), the number of days.
  • This is followed by \(m\) space-separated integers representing the daily sales numbers.

outputFormat

Output a single line with \(n\) integers separated by a space. Each integer indicates the length of the longest strictly increasing or strictly decreasing streak for the corresponding product.

## sample
2
6 3 5 2 8 11 6
4 1 2 4 3
3 3

</p>