QOJ.ac

QOJ

Limite de temps : 1 s Limite de mémoire : 128 MB Points totaux : 100

#16141. Building Green Belts

Statistiques

To enhance the scenery of a park, a flower bed needs to be built, surrounded by a green belt that encloses the flower bed.

If the park is viewed as an $M \times N$ rectangle, the flower bed can be viewed as a $C \times D$ rectangle, and the green belt together with the flower bed can be viewed as an $A \times B$ rectangle.

If the "fertility" of each piece of land in the garden is defined as the sum of the fertility of each small plot on that land, then: Fertility of the green belt = (Fertility of the $A \times B$ area) - (Fertility of the $C \times D$ area).

To ensure the green belt grows vigorously, we want to maximize the fertility of the green belt.

Input

The first line contains 6 positive integers $M, N, A, B, C, D$. The following lines contain an $M \times N$ matrix of numbers, where the element in the $i$-th row and $j$-th column is an integer $X_{ij}$, representing the "fertility" of the land at the $i$-th row and $j$-th column of the garden.

Output

A single positive integer representing the maximum fertility of the green belt.

Examples

Input 1

4 5 4 4 2 2
20 19 18 17 16
15 14 13 12 11
10 9 8 7 6
5 4 3 2 1

Output 1

132

Constraints

30% of the data: $1 \le M, N \le 50$ 100% of the data: $1 \le M, N \le 1000$, $1 \le A \le M$, $1 \le B \le N$, $1 \le C \le A-2$, $1 \le D \le B-2$, $1 \le \text{"fertility"} \le 100$

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.