Example: Suppose M = 20 , n = 4
{ x1 , x2 , x3 , x4 } = { 6 , 7 , 12 , 14 }
AND { r1 , r2 , r3 , r4 } = { 5 , 6 , 5 , 1 }
Then the optimal solution would be to place billboards at x1 and x3 for total revenue of 10.
Give an algorithm that takes an instance of this problem as input and returns the maximum total revenue that can be obtained from any valid subsets of sites.
buy Yahoo, buy eBay, buy Yahoo, buy Oracle ## occur in this sequence S, in order but not necessarily consecutively. They begin with a finite collection of possible events (e.g. the possible transactions) and a sequence S of n of these events. A given event may occur multiple times in S (e.g. Yahoo stock may be bought many times in a single sequence S). We will say that a sequence S' is a subsequence of S if there is a way to delete certain of the events from S so that the remaining events, in order, are equal to the sequence S'. So for example, the sequence of four events above is a sub-sequence of the sequence
buy Amazon, buy Yahoo, buy eBay, buy Yahoo, buy Yahoo, buy Oracle ## Their goal is to be able to dream up short sequences and quickly detect whether they are subsequences of S. So this is the problem they pose to you: Give an algorithm that takes two sequences of events --- S' of length m and S of length n, each possibly containing an event more than once --- and decides in time O (m + n) whether S' is a subsequence of S.