AmazonOA #202
Get Max Increments
估计中等可在线判题
Rearrange all the integers in any order to maximize the number of adjacent positions with a[i]<a[i+1]. This is not the longest increasing subsequence.
输入格式
The first line contains n; the second line contains the scores. 2≤n≤200000, 1≤score≤200000.
输出格式
Output a single integer, the answer.
样例 1
输入:
3
2 1 3
输出:
2
样例 2
输入:
4
2 1 1 2
输出:
2
样例 3
输入:
2
5 5
输出:
0
样例说明
The answers are 2, 2 and 0; in the second example the arrangement 1,2,1,2 rises at positions 0 and 2, and the source's 0 and 1 is wrong.