title: Maximal sum of products of two lists
body: <p>I need to write an algorithm based on dynamic programming approach and to be honest I got completely stuck. </p>
  
  <p>Ok, so the problem is like that. I have two lists with the same (even) length. For example let's say that:</p>
  
  <pre><code>a = [43, 10, 40, 12]
  b = [63, 73, 5,  13]
  </code></pre>
  
  <p>I need to use the dynamic programming approach to find maximal sum of products of paired numbers from those lists. The numbers can be only paired in such a way that:</p>
  
  <p><code>(a[n] * a[n+1]) V (b[n] * b[n+1]) V (a[n] * b[n])</code></p>
  
  <p>And obviously if you chose one of those combinations you can't use those numbers anymore. </p>
  
  <p>What I actually need help with is finding the recursive function for that. And I really can't find it. Would be really grateful if someone could give me a hand with that. </p>
  
  <p>Best regards</p>