Maximum Sum Submatrix

0

0 votes
Hard
Problem

You are given a N x M matrix containing N rows and M columns.

You need to find a sub matrix U x V such that

  1. U is equal to V.
  2. Sum of its elements is atmost X.
  3. Its area (number of elements) is as large as possible.

Input

The first line contains three integers N and M.

Second line of input contains X maximum possible sum of elements.

Next N lines contain M space separated integers.

 

Output

Print maximum area of the desired submatrix.

 

Constraints

1 ≤n,m≤ 103.

1 ≤ x ≤ 1018.

1 ≤ A[i][j] ≤ 109.

Time Limit: 1
Memory Limit: 256
Source Limit:
Editor Image

?