Problems
Max Chunks To Make Sorted
Max Chunks To Make Sorted
There is an integer array of length $n$ that represents a permutation in the range $[0, n - 1]$.
Let's split an array into some number of chunks (partitions), and individually sort each chunk. After concatenating them, the result should equal the sorted array.
Find the largest number of chunks we can make to sort the array.
\InputFile
The first line contains the size of array $n\:(n \le 10^5)$. The second line contains $n$ integers - a permutation in the range $[0, n - 1]$.
\OutputFile
Print the largest number of chunks we can make to sort the array.
Input example #1
5 4 3 2 1 0
Output example #1
1
Input example #2
5 1 0 2 3 4
Output example #2
4