6705.Collecting Numbers

Time Limit: 1s Memory Limit: 512MB

You are given an array that contains each number between $1 \dots n$ exactly once. Your task is to collect the numbers from $1$ to $n$ in increasing order.

On each round, you go through the array from left to right and collect as many numbers as possible. What will be the total number of rounds?

Input Format(From the terminal/stdin)

The first line has an integer $n$ : the array size.

The next line has $n$ integers $x_1,x_2,\dots,x_n$ : the numbers in the array.

  • $1 \le n \le 2 \cdot 10^5$

Output Format(To the terminal/stdout)

Print one integer: the number of rounds.

Sample Input

Copy
5
4 2 1 5 3
 \n
 · · · · \n

Sample Output

Copy
3
 \n
Source: CSES, Sorting and Searching, 2216

Submit

请先 登录

© 2025 FAQs