32 lines
522 B
C++
32 lines
522 B
C++
#include <algorithm>
|
|
#include <iostream>
|
|
#include <vector>
|
|
using namespace std;
|
|
|
|
int main() {
|
|
freopen("outofplace.in", "r", stdin);
|
|
size_t n;
|
|
|
|
cin >> n;
|
|
|
|
vector<int> heights(n);
|
|
|
|
for (int &height : heights) {
|
|
cin >> height;
|
|
}
|
|
|
|
vector<int> sortedHeights(heights);
|
|
sort(sortedHeights.begin(), sortedHeights.end());
|
|
|
|
int bad = 0;
|
|
for (int i = 0; i < n; i++) {
|
|
if (sortedHeights[i] != heights[i]) {
|
|
bad++;
|
|
}
|
|
}
|
|
|
|
freopen("outofplace.out", "w", stdout);
|
|
cout << bad - 1;
|
|
return 0;
|
|
}
|