#P9276. [AGM 2023 资格赛] 麦田
[AGM 2023 资格赛] 麦田
Problem Description
Recently, you inherited a piece of land from your great-great-grandfather. This land is a rectangle with rows and columns. You want to continue your great-grandfather’s legacy and start planting two types of plants: wheat and sunflowers.
In each cell of the field, you can plant seeds of one of the two plants. Planting wheat in cell earns euros, while planting sunflowers in the same cell earns euros.
Unfortunately, you soon discover that if you plant different types of plants in adjacent cells, their roots will get tangled together, and you will need to spend a lot of money to fix it.
Now you urgently want to know: if in every cell you plant only one of the two types of seeds, what is the maximum amount of money you can obtain.
Input Format
The first line contains two integers and , representing the number of rows and columns.
The next lines contain integers .
The next lines contain integers .
The next lines contain integers , representing the loss if different seeds are planted in cells and .
The next lines contain integers , representing the loss if different seeds are planted in cells and .
Output Format
Output one number, the answer.
2 2
1 6
7 1
5 1
1 3
1
1
2 1
16
Hint
Translated by ChatGPT 5