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