#K10031. Max Product Pair
Max Product Pair
Max Product Pair
You are given an integer N and an array of integers A of size N. Your task is to find a pair of distinct elements A[i] and A[j] (with i < j) such that the product $A[i]\times A[j]$ is maximized. If more than one pair yields the same maximum product, choose the pair with the smallest index i.
Note: The pair should be output as two indices separated by a space.
Example:
For N = 5 and A = [1, 20, 3, 4, 5], the answer is 1 4
because 20 \times 5 = 100 is the maximum product.
inputFormat
The first line contains an integer N representing the number of elements in the array. The second line contains N space-separated integers, the elements of the array A.
outputFormat
Output two integers i and j (0-indexed) separated by a space, representing the indices of the two numbers whose product is maximum. If multiple pairs have the same product, output the pair with the smallest index i.
## sample5
1 20 3 4 5
1 4