阿摩線上測驗 登入

申論題資訊

試卷:109年 - 109國立臺灣大學_碩士班招生考試_資訊工程學研究所:資料結構與演算法(A)#106053
科目:台大◆資工◆資料結構與演算法(A)
年份:109年
排序:0

題組內容

12. (15 points) There are n stations along a coastal railway (n > 0). You're planning to select some of them to open cafes. Three arrays S, L and R have been given, including
ㆍS=(s1,s2,..., sn): the list of the stations froun s1 (first) to sn (last).
ㆍL=(l1,l2,...,ln): the locations of the stations, where li is the distance of s from the first station s1. So l1 = 0 and In is the length of the railway.l1<l2<...<ln.
ㆍ R= (r1, r2, ...rn): the revenues of the cafes, where ri (> 0) is the revenue for opening a cafe in si.
The only one constraint in your plan is that the distance of any pair of your selected stations should be longer than a given threshold T. If si and sj (i # j) are selected, the total revenue would be li + ly. Different selection leads to different total revenue. Given S, L, R and T, your goal is to pick up a subset of the stations to maximize the total revenue under the constraint. Suppose that f(n) returus the maximum total revenue for the cafes you select from the first n stations. Please answer the following questions. No code is required (code will not be graded).

申論題內容

(a) (9 points) Give an O(n2) solution by deining a recurrence fornula for f(n). Clearly explain the meaning of your formula and why it can be computed in O(n2) time.