B has a smaller array of length n a, she wanted to sort the array.
However, small b lazy, she felt too tired to sort the entire array, so she will make you into a number of blocks, so that she only needs to sort each piece separately, will be able to sort the entire array.
Will you be able to be divided into a maximum of how many pieces.
A guarantee of a permutation of 0 ... n-1.
Sample explained:
The divided into a two or more blocks, you can not obtain the desired results. For example, divided into [4, 3], [2, 1, 0], the results obtained are sorted [3, 4, 0, 1, 2], this is not an ordered array.
Entry
The first line of a number n; the number of the second row and n represents a [i], separated by a space. n <= 10
Export
A number output indicative of the division number of blocks
SAMPLE INPUT
5
4 3 2 1 0
Sample Output
1
If ij can be divided into one, then this is where the minimum is the maximum i j.
Code:
#include <iostream> #include <cstdlib> #include <cstdio> #include <vector> using namespace std; int n,c,d; int s[10]; int main() { scanf("%d",&n); for(int i = 0;i < n;i ++) { scanf("%d",&d); if(i) s[i] = max(d,s[i - 1]); else s[i] = d; if(s[i] == i) c ++; } printf("%d",c); }