Special Pairs.
You are given an array A of N elements. You have to find number of Special Pairs such that i < j (0\(\leq\) i , j \(\leq\)N-1) and A[i] > 2*A[j].
Input Format
- First line contains a single integer N - number of elements in the array
- Second line contains N integers A0, A1, … , AN-1 - elements of an array A.
Output Format
A single integer denoting the number of Special Pairs.
Constraints
- 1 \(\leq\) N \(\leq\) 106
- 1 \(\leq\) Ai \(\leq\) 109
Sample Input 0
5
1 3 2 3 1
Sample Output 0
2
Sample Input 1
5
2 4 3 5 1
Sample Output 1
3
Open on HackerRank ↗ · Markdown source · Back to the archive