The question I ask here is already asked before the stack overflows. But I can not correctly understand the solutions sent by Skiminok .
Here's the link .
I tried the solution posted at the above link, with two examples of test cases, but I can not get the correct answer.
For test case 1 ::
N = 3 and K = 2
5 4 7
DAG will be ::

Note. I built the above DAG group considering:
Let pi and pj be two different tasks. Then we draw a directed edge from pi to pj if and only if pj can be solved immediately after pi on the same day, sequentially. Namely, the following conditions must be met:
i <j, because you have to solve the less complicated problem before.
| vi - vj | > = K (assessment requirement).
, ::
(u, v) DAG (au, bv) , {ai} {bi} - n.

= .
= 1 ( egde)
2.
2:
5 1
5 3 4 5 6


MAx , 1.
, , , , . - .
!