怎么用动态规划解决选教室的有关问题

如何用动态规划解决选教室的问题?
consider the following set S of activities, which we have sorted in monotonically increasing order of finish time:

--------------------------------------------
i 1 2 3 4 5 6 7 8 9 10 11
si 1 3 0 5 3 5 6 8 8 2 12
 
fi 4 5 6 7 8 9 10 11 12 13 14
 

(We shall see shortly why it is advantageous to consider activities in sorted order.) For this example, the subset {a3, a9, a11} consists of mutually compatible activities. It is not a maximal subset, however, since the subset {a1, a4, a8, a11} is larger. In fact, {a1, a4, a8, a11} is a largest subset of mutually compatible activities; another largest subset is {a2, a4, a9, a11}.

si 数组表示活动开始时间
fi 数组表示活动结束时间

算法导论用贪婪法解决 然后给出个用动态规划解决的习题
一直不会做
算法导论16.1节
高手帮帮忙 给点代码看看

------解决方案--------------------
哥,难道你就是aa排名第一的鸟房,不要退出啊,换个ID继续打嘛,或者再跟安大的那厮再搞一局??