title: Find the pair than minimizes the value of a function with two parameters
body: <p>I have an function F(x, y) where x and y are integers and two arrays a, b with n elements each. I need to find two numbers i, j which make the value of F(a[i], b[j]) minimum. Is there a better aproach than searching all the n^2 different combinations? The function F returns a different value for different parameters.</p>
  
  <p>EDIT: In my problem the arrays a, b represent n cannonballs fired by two opposing armies in two points of a straight line, starting at time=0. The function is an oracle that returns the exact time that two of them collide and I need to find the couple that collides first. If they do not collide the oracle returns the time that they would collide if there were no other cannonballs.</p>