Removal of billboards from given ones

前端 未结 7 1911
Happy的楠姐
Happy的楠姐 2020-12-14 11:46

I came across this question

ADZEN is a very popular advertising firm in your city. In every road you can see their advertising billboards. Recentl

7条回答
  •  一向
    一向 (楼主)
    2020-12-14 12:33

    soulcheck's (second) DP solution is correct in principle. There are two improvements you can make using these observations:

    1) It is unnecessary to allocate the entire DP table. You only ever look at two rows at a time.

    2) For each row (the v in P(v, i)), you are only interested in the i's which most increase the max value, which is one more than each i that held the max value in the previous row. Also, i = 1, otherwise you never consider blanks.

提交回复
热议问题