#K3906. Min Partition Score
Min Partition Score
Min Partition Score
Given a sequence of n integers, you are required to partition the sequence into strictly increasing continuous subsequences. The total score of a partition is defined as the number of indices i (with 1 ≤ i < n) such that \(a_i \ge a_{i+1}\). In other words, every time the sequence fails to increase from one element to the next, it contributes 1 to the score. Your task is to compute the minimum possible total score.
The score can be formulated as:
[ \text{score} = #{ i \mid 1 \le i < n,\ a_i \ge a_{i+1} } ]
For example, consider the sequence [1, 2, 3, 2, 4]. The score is 1 because the only decrease occurs from 3 to 2.
inputFormat
The input is given via standard input (stdin) and consists of two lines:
- The first line contains a single integer \(n\) (\(1 \le n \le 10^5\)), representing the length of the sequence.
- The second line contains \(n\) space-separated integers representing the sequence.
outputFormat
Output a single integer to standard output (stdout) — the minimum possible total score, which is equivalent to the number of positions where the sequence is not strictly increasing.
## sample1
1
0