Give O(n log n) algorithm for pairs (i<j) with a_i > 2*a_j
Analyze the give o(n log n) algorithm for pairs (i<j) with a_i > 2*a_j.
Examples
Input:"test_input_1"
Output:"output_1"
Input:"test_input_2"
Output:"output_2"
Hints
Consider how merging two sorted subarrays can help count pairs where `a_i > 2*a_j` efficiently.
Use a modified merge step to count valid pairs while merging, similar to inversion counting but with a stricter condition.
Extend the approach by recursively solving subproblems and combining results, ensuring the condition `a_i > 2*a_j` is maintained across subarray boundaries.
Give O(n log n) algorithm for pairs (i<j) with a_i > 2*a_j
Analyze the give o(n log n) algorithm for pairs (i<j) with a_i > 2*a_j.