Number of inversions#4261

Number of inversions

1 sekunt
128 megabaýt
Ýeňil

Write a program that finds for a given array A = \langle a_1, a_2, \ldots, a_n \rangle the number of such pairs that i < j and a_i > a_j.

Giriş

The first line contains the number of array elements (1 \le n \le 50000). Second line contains different elements of array - nonnegative integers, not greater than 10^6.

Çykyş

Print the number of required pairs.

Mysallar

1-nji mysal

Loading
Loading

2-nji mysal

Loading
Loading