Minimum sum combination on selecting one element for each index out of 3 arrays

69 Views Asked by At

Given 3 non-sorted indexed sequence of real numbers. Out of the combinations obtained by selecting exactly one element out of 3 elements (one from each array) with same index, which combination yields sum with minimum absolute value? All elements are real numbers and can be negative.

First array : a1, a2, a3, ..., an
Second array : b1, b2, b3, ..., bn
Third array : c1, c2, c3, ..., cn

One combination on selecting one element from each index is
a1, b2, c3, a4, b5, c6, ... ,cn

The sum of this combination is a1 + b2 + c3 + ... + cn.
I am trying to find the combination with minimum absolute value of sum.

There are 3^n such combinations and hence iterating through all of them is not possible for high value of n (~10 million). Any help is highly appreciated.