Account
GitHubFeedback
Drafts and results saved on this device
Submit on CSES.fi
CSES Problemset/Sorting and Searching

Collecting Numbers

#2216
Ask AI

Open a hint-first prompt in a new AI chat. Grok may ask you to confirm before sending.

Open Claude Desktop

Time limit:1.00 s
Memory limit:512 MB
Unsolved
Download Tests (.zip)

You are given an array that contains each number between 1…n1 \dots n exactly once. Your task is to collect the numbers from 11 to nn 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

The first line has an integer nn: the array size.

The next line has nn integers x1,x2,…,xnx_1,x_2,\dots,x_n: the numbers in the array.

Output

Print one integer: the number of rounds.

Constraints
  • 1≤n≤2⋅1051 \le n \le 2 \cdot 10^5
Sample Test Cases (1)
Example 1ID: sample-1
Input
5
4 2 1 5 3
Expected Output
3
Tools
1
2
3
4
5
6
7
8
9
10
11
12
Draft saved locally
|1 line, 0 chars
Test Bench
Download .zip
Input (stdin)
5
4 2 1 5 3
Expected Output
3