All Tracks Problem

The Counting Problem
Tag(s):

Medium

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
Marking Scheme: Marks are awarded when all the testcases pass.
Allowed Languages: C, C++, C++14, Clojure, C#, D, Erlang, F#, Go, Groovy, Haskell, Java, Java 8, JavaScript(Rhino), JavaScript(Node.js), Julia, Kotlin, Lisp, Lisp (SBCL), Lua, Objective-C, OCaml, Octave, Pascal, Perl, PHP, Python, Python 3, R(RScript), Racket, Ruby, Rust, Scala, Swift, Swift-4.1, Visual Basic

CODE EDITOR

Initializing Code Editor...
Your Rating:

Contributor

This Problem was Asked in

Jalpaiguri Government Engineering College

Challenge Name

Code Chronicles Season 3

OTHER PROBLEMS OF THIS CHALLENGE
Notifications
View All Notifications

?