Current work
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
#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;
|
||||
}
|
||||
Reference in New Issue
Block a user