Print? 1. For the one-dimensional problem, the maximum sum of consecutive sub-segments in a sequence is solved.
Status: one-dimensional array dp [I]: The maximum sub-segment ending with I, not the maximum sub-segment and of the previous I item. The two are different.
Transfer: if dp [I]> 0
Dp [I + 1] = dp [I] + a [I]
Else
Dp [I + 1] = dp [I]
Ans = max (dp [k]; k = 1, 2,... n ),
The principle of scrolling array can be used to optimize the space. The space complexity is O (1 ).
If ans> 0 dp + = a [I]
Else dp = a [I]
Ans = max (dp)
<A href = "http://acm.hit.edu.cn/hoj/problem/view? Id = 1760 "target = _ blank> hoj 1760 The jackpot </A>
2. Two-dimensional.
The sum [I] [j] indicates the sum of column 1st> j in each row (column.
Enumerate all rectangles with the complexity of O (n ^ 3), enumerate one row and two columns.
For a rectangle, the rows are reduced to a vertex, and the column is transformed into a one-dimensional problem.
Hoj 2558 maxsum
3. 3D
It is similar to converting two-dimensional data into one-dimensional data.
First, the two-dimensional matrix and of the bottom surface (or other surface) are preprocessed.
Sum [I] [j] [k]: Elements of the matrix at layer I with the diagonal endpoint () and (j, k.
Then, we use the complexity of O (n ^ 5) to enumerate all cubes, compress the bottom surface into a vertex, and process the remaining one dimension as one dimension.
Hoj 2555
1. For the one-dimensional problem, the maximum sum of consecutive sub-segments in a sequence is solved.
Status: one-dimensional array dp [I]: The maximum sub-segment ending with I, not the maximum sub-segment and of the previous I item. The two are different.
Transfer: if dp [I]> 0
Dp [I + 1] = dp [I] + a [I]
Else
Dp [I + 1] = dp [I]
Ans = max (dp [k]; k = 1, 2,... n ),
The principle of scrolling array can be used to optimize the space. The space complexity is O (1 ).
If ans> 0 dp + = a [I]
Else dp = a [I]
Ans = max (dp)
House 1760 The jackpot
2. Two-dimensional.
The sum [I] [j] indicates the sum of column 1st> j in each row (column.
Enumerate all rectangles with the complexity of O (n ^ 3), enumerate one row and two columns.
For a rectangle, the rows are reduced to a vertex, and the column is transformed into a one-dimensional problem.
Hoj 2558 maxsum
3. 3D
It is similar to converting two-dimensional data into one-dimensional data.
First, the two-dimensional matrix and of the bottom surface (or other surface) are preprocessed.
Sum [I] [j] [k]: Elements of the matrix at layer I with the diagonal endpoint () and (j, k.
Then, we use the complexity of O (n ^ 5) to enumerate all cubes, compress the bottom surface into a vertex, and process the remaining one dimension as one dimension.
Hoj 2555