CanvaOA #2
Order Check (Backend)
Estimated EasyJudge-ready
Topics (AI-labelled)In-place Arrays
After sorting by height in ascending order, count the students in the original array who are not in their correct position.
This site's standard I/O format and any supplementary ranges follow this problem's statement.
Input
n (1≤n≤100000), and the next line contains n heights (1≤height[i]≤10^9). The value ranges come from the original problem.
Output
Output the number of students in incorrect positions.
Example 1
Input:
6
1 1 3 3 4 1
Output:
3
Example 2
Input:
5
1 1 3 4 1
Output:
3
Example 3
Input:
1
1
Output:
0
Editorial
Loading solution…