#P1935. [国家集训队] 圈地计划
[国家集训队] 圈地计划
Description
Recently, the real estate developer GDOI (Group of Dumbbells Or Idiots) obtained a piece of land for development from NOI (Nuts Old Idiots). This land is a rectangular area that can be divided into small cells. GDOI requires dividing these cells into a commercial zone and an industrial zone for development. Due to different terrain conditions, building a commercial zone or an industrial zone on each cell will yield different economic values. More specifically, for the cell in the -th row and -th column, building a commercial zone yields revenue , and building an industrial zone yields revenue . In addition, adjacent cells can bring extra revenue: if cell has neighboring cells (adjacency means two cells share a common side) whose type is different from that of , then this cell gains an additional revenue of . After Professor Tiger.S’s survey, the revenue matrices , , and are known. Can you help GDOI find a plan that maximizes the total revenue?
Input Format
The first line contains two integers, positive integers and , representing the number of rows and columns of the area, respectively.
Lines to : each line contains integers, representing the commercial revenue matrix .
Lines to : each line contains integers, representing the industrial revenue matrix .
Lines to : each line contains integers, representing the extra revenue matrix for adjacent cells.
Output Format
Output a single line containing one integer, the maximum total revenue.
3 3
1 2 3
4 5 6
7 8 9
9 8 7
6 5 4
3 2 1
1 1 1
1 3 1
1 1 1
81
Hint
, .
Translated by ChatGPT 5
京公网安备 11011102002149号