| Author: | Pavel Mesenev | Time limit: | 3 sec | |
| Input file: | Standard input | Memory limit: | 256 Mb | |
| Output file: | Standard output |
You are given an array of n integers a0, a1, …, an − 1, possibly negative. A significant reverse pair is a pair of indices i < j with ai > 2 ⋅ aj.
Count the significant reverse pairs.
The first line contains one integer n. The second line contains n space-separated integers a0… an − 1.
Print one integer — the number of pairs i < j with ai > 2 ⋅ aj.
1 ≤ n ≤ 2 ⋅ 105
− 109 ≤ ai ≤ 109
The answer fits into a signed 64-bit integer.
| No. | Standard input | Standard output |
|---|---|---|
| 1 |
|
|
| 2 |
|
|
| 3 |
|
|