Problem
An inversion of an array is a pair of indices such that and . The number of inversions shows how far the array is from being sorted: if it is already sorted then there are no inversions, whereas if it is sorted in reverse order then the number of inversions is maximal.
Given: A positive integer and an array of integers from to .
Return: The number of inversions in .
问题
数组倒置 是一对指数 这样 和 。反转次数显示了数组的排序距离:如果已经排序,则没有反转,而如果以相反顺序排序,则反转次数最大。
给定:正整数 和一个数组 来自的整数 至 。
返回值:的倒数。
Sample Dataset
5 -6 1 15 8 10
Sample Output
2