Submit solution
Points:
30 (partial)
Time limit:
1.0s
Memory limit:
16M
Author:
Problem type
Allowed languages
C, C++, Java, Pascal, Python
INVCOUNT
Given a sequence of integers , , , find the number of inversions. Two numbers in the sequence , form an inversion if and .
For example, in the sequence , , , , , there are inversions: , , and .
The numbers in the sequence are all distinct from each other.
Input
The first line contains the number . The next line contains the numbers separated in pairs by a space.
Output
An integer corresponding to the number of inversions in the sequence.
Constraints
Time Limit: 1 sec.
Maximum Available Memory: 16 MB.
Example of Input - Output
STDIN (invcount.in)
5
2 8 1 3 10
STDOUT (invcount.out)
3
Comments