[hdoj]2845 Beans

Source: Internet
Author: User

Problem-solving ideas: The first idea is divided into two lines, each line to find a maximum, single and double lines are summed separately. For each row to maximize, for each position may be empty a position is not selected, it is possible to empty two locations not selected, but not empty three, otherwise it will definitely add the middle value. For each line of search not, linear storage search is not wasted? 200000 of the data can only be DP. After finding the maximum value for each row, the same state transfer equation is used to calculate the maximum value for the column.

State transition equation:dp[j]=max (dp[j-2]+a[j],dp[j-1]);

When dynamic planning assigns initial values, remember not to assign errors. For example this problem, dp[2] may =dp[1];
As for the subscript out of bounds what situation I do not build ... To save time, C and C + + do not rigorously review array subscript cross-border issues

The address of the array labeled-1 is out of bounds for the array, but this address is meaningful

This address is the address that corresponds to the forward offset of the first address of the requested array storage space (that is, the number of bytes that are offset by the current array type).

This address is not initialized with the array space,
So the data is not necessarily,
If the address space is being used in the system or other apps, then it can be accessed, and the meaning of the data depends on the data written by the system or other apps, but after access, it can cause system or other app exceptions.
If the address is not used, then is a wild address, then the data is random, meaningless
The above is the answer from the Internet search

hdu2845

[hdoj]2845 Beans

Related Article

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.