#K47867. Maximum Subgrid Sum
Maximum Subgrid Sum
Maximum Subgrid Sum
You are given an \(n \times m\) grid of integers and two integers \(a\) and \(b\) which specify the size of a subgrid. Your task is to find the maximum sum of any contiguous \(a \times b\) subgrid within the given grid.
The sum of a subgrid is defined as the sum of all the integers inside it. For example, given the grid below and \(a = 2,\ b = 2\):
1 2 3 4 5 6 7 8 9
the maximum subgrid sum is \(28\), which comes from the subgrid:
5 6 8 9
Solve the problem such that your program reads input from stdin and writes the result to stdout.
inputFormat
The first line of input contains four integers: \(n\), \(m\), \(a\), and \(b\). Here, \(n\) and \(m\) represent the number of rows and columns of the grid, and \(a\) and \(b\) represent the number of rows and columns of the subgrid respectively.
This is followed by \(n\) lines, each containing \(m\) space-separated integers representing the grid.
outputFormat
Output a single integer: the maximum sum of any \(a \times b\) subgrid in the given grid.
## sample3 3 2 2
1 2 3
4 5 6
7 8 9
28
</p>