All Tracks Problem

The Counting Problem
/
No tags
Problem
Editorial
Analytics

Souvik loves counting. He has a habit of generating any random logic and follow the same to start counting anything.

So one fine day he got an array of numbers. He, as usual could not resist the urge of counting and counted the number of elements of the array. But that was quite easy and Souvik didit quite easily. But he didn’t want the excitement to die down so easily. So he thought of a new logic.

He took the array and counted all the pair of integers such that i < j and A[i]>A[j], A being the array. As this is a tedious task, Souvik has turned to you to help him with the counting.

INPUT
First line of input will consist of a single integer T denoting number of test-cases. Each test-case will consist of two lines. First line will have a single integer N denoting number of integers in the array. Next line will contain N space separated integers denoting the contents of the array.

OUTPUT
For each test case, output a single integer denoting the total number of pairs satisfying the above condition.

CONSTRAINTS

  • 1<=T<=100
  • 1<=N<=105
  • 0<=A[i]<=105

SAMPLE INPUT
2
7
3 1 7 4 2 8 5
6
11 8 15 1 4 10
SAMPLE OUTPUT
7
9
Time Limit: 1.0 sec(s) for each input file.
Memory Limit: 256 MB
Source Limit: 1024 KB

Best Submission

Similar Problems

Contributors

This Problem was Asked in

Initializing Code Editor...
Notifications
View All Notifications

?