題組內容
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 si from the first station s1. So l1 = 0 and In is the length of the railway.l1<l2<...<ln.
ㆍ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 si 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).
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).