Inverse Pair

View as PDF

Submit solution


Points: 10 (partial)
Time limit: 1.0s
Memory limit: 32M

Author:
Problem type
Allowed languages
Python

Problem Statement

Given a list L, please determine the number of inverse pairs in L, where an inverse pair is defined as L[i] > L[j] and i < j.

Input Specification

The first line of the input gives the number of test cases, T, T test cases follow.

Each test case consists of a line.

The line contains the elements in L,seperated by a space.

Limits

Memory limits: 32MB.

Time limits: 1 second.

1 \leq T \leq 100

1 \leq \text{length of L} \leq 100

1 \leq L[i] \leq 1000, where 0 \leq i < \text{length of L}

Test Set 1

Sample Case

Test Set 2

1 \leq \text{length of L} \leq 10

Test Set 3

1 \leq \text{length of L} \leq 50

Test Set 4

1 \leq \text{length of L} \leq 100

Output Specification

For each test case, output one line containing Case #x: y, where x is the case number(starting from 1) and y is the number of inverse pairs in L.

Sample Input

3
1 2 3 4
2 5 4 3
5 5 1 1

Sample Output

Case #1: 0
Case #2: 3
Case #3: 4

Hint

loop if-else


Comments

There are no comments at the moment.