1373: 求逆序对

Memory Limit:128 MB Time Limit:1.000 S
Judge Style:Text Compare Creator:
Submit:53 Solved:30

Description

给定一个序列 a1,a2,…,an,如果存在 i<j 并且 ai>aj,那么我们称之为逆序对,求逆序对的数目。

Input

第一行为 n,表示序列长度,接下来的 n 行,第 i+1 行表示序列中的第 i 个数。

Output

所有逆序对总数。

Sample Input Copy

4
3
2
3
2

Sample Output Copy

3

HINT

N<=105 ,A i <=105

Source/Category