-->
当前位置:首页 > 题库 > 正文内容

PROGRAMMING:Reverse order pair

Luz3年前 (2021-05-10)题库236
Given an integer sequence of length N, please calculate the number of reverse order pairs in the sequence.
The definition of reverse order pair is as follows: for the i-th and j-th elements of a sequence, if I < J and a [i] > a [J], it is a reverse order pair; Otherwise it's not.
###Input format:
The first line contains the integer n, which represents the length of the sequence; The second line contains n integers, representing the entire sequence( 1≤n≤100000)
###Output format:
Output an integer that represents the number of reverse order pairs.
###Input example:
```in
six
2 3 4 5 6 1
```
###Output example:
```out
five
```







answer:If there is no answer, please comment

发表评论

访客

◎欢迎参与讨论,请在这里发表您的看法和观点。