Interval Scheduling problem with more than 1 machine
You may want to consider a solution with dp(i, j, k) where i represents the x that machine 1 is at, j represents the x that machine 2 is one, and k represents the index of the task you're considering
The state transition in this case would be O(1) because you either take the task or not, for which you can increment/decrement i/j accordingly.
I'm not sure what D and n are but if D refers to the amount of time allotted for machine 1 and 2 and n is the number of tasks, then I believe this could be the solution you're looking for
Note that &quot;x&quot; refers to time. Also, this solution would work if the tasks were assigned a value
Let me know if you want an implementation of this