title: Select M items from N items such that completing these M item's tasks take the minimum time
body: <p>I'm trying to solve the following problem:
  You are given N items. Each item contains three tasks A, B and C. The time required to complete task A is TA, task B is TB, task C is TC. Now, we must select M items such that completing these M item's tasks take the minimum time. And here are the rules:</p>
  <ol>
  <li>All selected M items are operated simultaneously, i.e. tasks of all the M items are operated at the same moment</li>
  <li>The task B of any selected items cannot be started unless task A of all M items is complete</li>
  <li>The task C of any selected items cannot be started unless task B of all M items is complete</li>
  </ol>
  <p>For example:</p>
  <pre><code>if say N = 3 and M = 2 (it means we must select M items out of 3 items in total)
           Tasks: A  B  C
         item 1 : 1  2  2
         item 2 : 3  4  1
         item 3 : 3  1  2
  </code></pre>
  <p>If we select item 1 and item 3, task A of both items gets completed after 3 units(item 1 waits for item 3 to finish), then task B of both the items gets completed after the next 2 units time. Similarly, task C gets completed after 2 units time. Hence the total time is 7(which is the minimum possible combination we can find)</p>
  <p>I have tried thinking of a Dynammic programming solution to the problem. But am unable to get a concrete solution to the problem. Could anyone help me out by giving a valid solution to the problem.</p>
  <p>PS: Please don't write the code. I am just looking for the logic here.</p>
  <p>Thank you in advance.</p>