| 시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
|---|---|---|---|---|---|
| 2 초 (추가 시간 없음) | 512 MB | 8 | 4 | 3 | 42.857% |
You are given a permutation.
A move is one of the following:
What is the minimum number of moves you need to make to sort the given permutation?
The first line contains a single integer $n$ (1ドル \leq n \leq 3 \cdot 10^5$), the length of the permutation.
The second line contains $n$ integers $a_i$ (1ドル \leq a_i \leq n$), the permutation itself.
Output a single integer --- the minimum number of moves you need to make to sort the given permutation.
1 1
0
2 1 2
0
3 3 2 1
1
4 4 2 1 3
2
5 4 1 5 3 2
4
6 1 5 3 4 2 6
5
7 3 2 1 7 6 5 4
9
8 4 2 6 1 5 3 7 8
8
9 9 8 7 6 5 4 3 2 1
22
10 8 2 9 5 1 7 10 4 6 3
17
11 7 2 3 9 11 1 8 6 4 10 5
23
12 3 10 6 2 4 12 7 8 5 1 11 9
18