blob: 8cdd9f03a9a8d7b65d87295024637eccb484beb2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
#include <iostream>
#include <utility>
int N;
int x[10010];
int main() {
std::ios_base::sync_with_stdio(false);
std::cin.tie(nullptr);
std::cin >> N;
for (int i = 1; i <= N; i++) {
std::cin >> x[i];
}
int result = 0;
for (int i = 1; i <= N - 1; i++) {
if (x[i] != i) {
for (int j = i + 1; j <= N; j++) {
if (x[j] == i) {
x[j] = x[i];
result++;
break;
}
}
}
}
std::cout << result;
return 0;
}
|