eizhao... wrote > wade wrote >> [EMAIL PROTECTED] wrote: >>> Is the solution always x = N-4, y = N-3, z = N-2 ? >>> Suppose we are looking for x and y to minimize the sum. >>> Sum = a[i]*x + a[j]*y, where 0 <= i <= x < j <= y <= N. >>> It is always bigger than a[i]*x + a[j]*x, because x < y and all numbers >>> are positive. >>> We have to have a y so when y is the last one, the sum is the minimum. >>> Similarly, z should be the last one too. >>> Any counterexample? >> a[] = { 1000000, 1, 1, 1, 1, 1, 1 }; >> It should be clear that you want x=0. > 0 < x < y < z < N-1 is the requirement.
Oops. It should be clear that you want x=1, not x=N-4 --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/algogeeks -~----------~----~----~----~------~----~------~--~---