cswork / OA打开练习工作台

TwilioOA #2

Find Maximum Greatness

估计中等可在线判题

考点(AI 标注)贪心调度双指针滑窗

Rearrange the array to maximize the number of indices where rearranged[i] > arr[i].

See "Input" for the standard input/output conventions and constraints added by this site.

输入格式

n≤100000, and array values are 1..10^9.

输出格式

Output the maximum value.

样例 1

输入:

3
1 3 5

输出:

2

样例 2

输入:

3
1 1 1

输出:

0

样例 3

输入:

4
1 2 2 3

输出:

2