#C7071. Minimum Increasing Subarray Partition

    ID: 50902 Type: Default 1000ms 256MiB

Minimum Increasing Subarray Partition

Minimum Increasing Subarray Partition

Given an array of n safety levels, partition the array into the minimum number of subarrays such that each subarray is strictly increasing. Formally, let \(A = [a_1, a_2, \dots, a_n]\) be the array. We want to split \(A\) into subarrays such that in each subarray \(a_i < a_{i+1}\). It can be shown that the minimum number of subarrays required is:

\[ \text{answer} = 1 + \sum_{i=2}^{n} \mathbf{1}\{a_i \leq a_{i-1}\} \]

where \(\mathbf{1}\) is the indicator function.

Your task is to compute this number given the list of safety levels.

inputFormat

The input consists of two lines:

  • The first line contains an integer n (\(1 \leq n \leq 10^5\)), representing the number of containers.
  • The second line contains n space-separated integers representing the safety levels of the chemicals.

outputFormat

Output a single integer representing the minimum number of strictly increasing subarrays required.

## sample
5
1 3 2 4 5
2