Codeforces #286 Div.2 C dp always beats me in an unexpected way.

Source: Internet
Author: User

The main idea: 30,001 Islands in a row, numbered from 0 to 30000, there are a total of n treasures scattered in these islands, a pig from 0 jump to D, after each step jump step and the previous step is not more than 1, the second step is d-1,d,d+1, the second step is the position of d+d-1,d+1, d+d+1 if d=1, then the next step can not be 0 long, after the treasure of the island will take away the treasure, ask him how many treasures can finally get.

Because (1+250) *250/2>30000, so the step size does not exceed 250--get tick

Must be Dp--get tick.

If the step in an island can be 1, then all the treasures behind this island can be--get.

The wrong thing to do is not to consider the current state DP[I][SP] from which states, such as dp[i-sp][sp-1],dp[i-sp][sp],dp[i-sp][sp+1]

and consider the current state DP[I][SP] can be used to give which state information such as dp[i+sp][sp-1],dp[i+sp][sp],dp[i+sp][sp+1]

To make a summary can be said that the post-push is certain, retrospective is not sure, but I was wondering why I always a look at the DP to know what to hang, comparing the above two lines on a plus minus, yesterday, there are people asked the knapsack problem of the forward for and reverse for what difference, I have not known for many years did not think, DP ancestors did not learn AH , not careful.

Now think about it, the backpack must be the current state to find the source to determine the value, because it is necessary to know the smaller size of the backpack placement, it is impossible to drop an item after the determination of the impact on the back.

Today came back to smell a piece of sweet, good like the salt taste of potato chips, canteen closed only two, copy hand a little greasy.

Codeforces #286 Div.2 C dp always beats me in an unexpected way.

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.