Basic DP 19 Channel

Source: Internet
Author: User

VJ Links: Click to open link

The basic DP is more beneficial!

Draw a few conclusions from it:

1. Knapsack problem The selected item is no correlation, is the filling property

2. The LIS problem is that there is a relationship between elements (multiple attributes are sorted first, based on another LIS)

3. TSP combinatorial problem, generally carry out the pressure, to find some sort of element order


Topic:

1. Maximum m sub-segment and

It's a lot like a multi-dimensional backpack problem with a number limit. At the same time, we can see that the last element can only be the last segment in the I sub-segment

DP[I][J] is used to represent the maximum value of the I field obtained by the first J item, and the last field ends with a num[j] item.
Dp[i][j]=max (DP[I][J-1]+NUM[J],DP (i-1,t) +num[j]) where i-1<=t<=j-1.
(because it must end with Num[j], so num[j] must belong to the last sub-segment, that is, either independently of itself into a sub-segment, or with a sub-segment ending with num[j-1] at the front)
The final result of the request is Max (Dp[m][j]) where 1<=j<=n.

Because the dp[i-1][t] appears before J, it is optimized for Edge loop edge seeking

Similar problem: The end of XX is the key to this kind of problem, is also the stage. Nine degrees Max addition and, LCS

2. Water problem

3. See test instructions is completely less than, first sort good area, then lis

4. Find the combination, TSP problem. Note that strings are sorted first, and the nature of the dictionary order is the smallest case.

5.LIS

6. Knapsack problem, using a hybrid backpack

7. The problem of the tower, the stage is clear. It's just the beginning, no basis t directly set up the stage, causing a lot of trouble

8. Water problem, note No 12 points, the display is 00. Optimal situation with I as the end

9. Two methods, ①: Since all the shells are to be beaten down, the shells will be used to store each time with the lowest one, the greedy strategy of higher shells to cope with the higher enemy.

②: Longest non-descending subsequence, dp[i] when deposited to i how many lis

10. After sorting the LIS, first let the weight order and then judge the speed

11. The problem with the backpack of the output path is that each time you have to backtrack to determine if you have used this element, the code is complex

12.LCS

13. Several tower problems, you can also put the initial point, from the back forward recursion. Note that each board has two points, one drop only to one plank

14.LIS n^2 Nlogn

15. I didn't read the question at first. You can only select from both ends of the given sequence at a time, and the sum is maximum. Interval DP

16. Like the previous ski, the transfer is conditional, so the sort is transferred again

17.DP[I][J] Sub-matrix with I,j as the starting point. From the upper right corner to the lower left corner of the recursion

18.LIS variants

19. This problem is difficult. To make a sequence of numbers become monotonous, so with the need to give some numbers plus, some minus. The number you want to become must be the number you already have (don't know why)

DP[I][J] At the end of the process to I, j is the minimum value. The numbers are initially copied in a sort order, thus guaranteeing "order" dp[i][j] = min (dp[i][j],dp[i-1][mn]+abs (a[i]-b[j));

MN is the minimum number of 0~j-1

Basic DP 19 Channel

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.