AmazonOA #61
Get Number Operations (Package Sorting Passes)
估计简单可在线判题
You are given a permutation of 1..n. In each round, scan from left to right and process the next not-yet-processed number as soon as you reach it; several numbers can be processed in a row within one round. Find how many rounds are needed to process all numbers.
输入格式
The first line contains n (1..1000000), and the second line contains a permutation of 1..n.
输出格式
Output a single integer answer.
样例 1
输入:
5
5 3 4 1 2
输出:
3
样例 2
输入:
1
1
输出:
1
样例 3
输入:
3
3 2 1
输出:
3
样例说明
Example 1: the first round processes 1, 2; the second 3, 4; the third 5, so the answer is 3. Example 2: a single scan finishes. Example 3: each round can process only one number, so the answer is 3.