Max Chunks To Make Sorted
Execution time limit is 1 second
Runtime memory usage limit is 128 megabytes
There is an integer array of length that represents a permutation in the range .
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.
Input
The first line contains the size of array . The second line contains integers - a permutation in the range .
Output
Print the largest number of chunks we can make to sort the array.
Examples
Input #1
Answer #1
Input #2
Answer #2
Submissions 104
Acceptance rate 54%