#C1560. Maximum Product Pair Indices
Maximum Product Pair Indices
Maximum Product Pair Indices
You are given an array of integers. Your task is to identify two distinct indices (0-indexed) such that the product of the corresponding elements is maximized. If there are multiple pairs yielding the same product, choose the pair with the smaller first index. If the array contains fewer than two elements, output -1 -1
.
The product is calculated using the formula: $$P = a_i \times a_j$$ where \(i < j\). The resulting indices must be printed in increasing order.
inputFormat
The first line contains an integer \(n\) representing the number of elements in the array. The second line contains \(n\) space-separated integers.
outputFormat
Output two space-separated integers representing the indices of the pair which gives the maximum product. If no valid pair exists, output -1 -1
.
1
1
-1 -1