#K62407. Minimum Increasing Subarrays Partitioning

    ID: 31524 Type: Default 1000ms 256MiB

Minimum Increasing Subarrays Partitioning

Minimum Increasing Subarrays Partitioning

You are given an array of integers. Your task is to partition the array into the minimum number of contiguous subarrays such that each subarray is strictly increasing. In other words, for each subarray \( S = [s_1, s_2, \dots, s_k] \), it must hold that \( s_1 < s_2 < \cdots < s_k \). If the array is empty, the answer is 0.

Example:

Input: 6
       1 2 1 2 3 1
Output: 3

Explanation: The array [1, 2, 1, 2, 3, 1] can be partitioned as follows:

  • [1, 2]
  • [1, 2, 3]
  • [1]

Thus, the minimum number of strictly increasing subarrays is 3.

inputFormat

The input is given via standard input (stdin) in the following format:

  1. The first line contains a single integer \( n \) representing the number of elements in the array.
  2. If \( n \) is positive, the second line contains \( n \) space-separated integers representing the array elements. If \( n = 0 \), no elements follow.

outputFormat

Output a single integer via standard output (stdout) which is the minimum number of contiguous subarrays needed such that each subarray is strictly increasing.

## sample
6
1 2 1 2 3 1
3