Question: C Programming Language ( Code With C Programming Language) Problem Title : Garden Fertility You have a garden of size N N. Each cell of
C Programming Language ( Code With C Programming Language)
Problem Title : Garden Fertility
You have a garden of size N N. Each cell of the garden has a value vij which represents the fertility of the cell. However, the maintenance cost of your garden is so high that you need to sell some cells of your land. You decided to keep a portion of your land of size M M which has the maximum fertility sum. In short, you need to determine the maximum fertility sum of all possible sub-rectangles of size M M!
Format Input
The first line consists of an integer N, the size of your garden. The next N lines each consists of N integers vij which represents the fertility value of cell (i, j). The last line of input consists of a single integer M, the size of the sub-rectangle.
Format Output
Output a single integer X which is the maximum fertility sum of all possible sub-rectangles of size M M.
Constraints
- 2 N 100
- 1 M < N
- 0 vi,j 1000000000
Sample Input & Output 1 (Standard Input & Output)
3 3 1 0 2 4 0 4 1 3 2 Max Fertility = 11
Sample Input & Output 2 (Standard Input & Output)
2 0 1 1 0 1 Max Fertility = 1
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
