title: algorithm to find longest non-overlapping sequences
body: <p>I am trying to find the best way to solve the following problem. By best way I mean less complex.</p>
  
  <p>As an input a list of tuples (start,length) such:</p>
  
  <pre><code>[(0,5),(0,1),(1,9),(5,5),(5,7),(10,1)]
  </code></pre>
  
  <p>Each element represets a sequence by its <em>start</em> and <em>length</em>, for example (5,7) is equivalent to the sequence <code>(5,6,7,8,9,10,11)</code> - a list of 7 elements starting with 5. One can assume that the tuples are sorted by the <code>start</code> element.</p>
  
  <p>The output should return a non-overlapping combination of tuples that represent the longest continuous sequences(s). This means that, a solution is a subset of ranges with no overlaps and no gaps and is the longest possible - there could be more than one though. </p>
  
  <p>For example for the given input the solution is:</p>
  
  <p><code>[(0,5),(5,7)]</code> equivalent to <code>(0,1,2,3,4,5,6,7,8,9,10,11)</code></p>
  
  <p>is it backtracking the best approach to solve this problem ?</p>
  
  <p>I'm interested in any different approaches that people could suggest.</p>
  
  <p>Also if anyone knows a formal reference of this problem or another one that is similar I'd like to get references.</p>
  
  <p>BTW - this is not homework.</p>
  
  <p><strong>Edit</strong></p>
  
  <p>Just to avoid some mistakes this is another example of expected behaviour</p>
  
  <p>for an input like <code>[(0,1),(1,7),(3,20),(8,5)]</code> the right answer is <code>[(3,20)]</code> equivalent to (3,4,5,..,22) with length 20. Some of the answers received would give <code>[(0,1),(1,7),(8,5)]</code> equivalent to (0,1,2,...,11,12) as right answer. But this last answer is not correct because is shorter than <code>[(3,20)]</code>.</p>