#K81807. Largest Rectangle in a Warehouse
Largest Rectangle in a Warehouse
Largest Rectangle in a Warehouse
You are given a binary grid representing a warehouse where each cell contains either a full box (denoted by 1) or an empty space (denoted by 0). Your task is to find the area of the largest rectangle that can be formed using only full boxes. The rectangle must be aligned with the grid (i.e. its sides are parallel to the rows and columns).
In mathematical terms, if a rectangle has height (h) and width (w), its area is given by (area = h \times w). Optimize your solution to compute the maximum possible area.
inputFormat
The input is read from standard input (stdin). The first line contains two integers (m) and (n), representing the number of rows and columns in the warehouse grid, respectively. This is followed by (m) lines, each containing (n) space-separated integers (each either 0 or 1), representing the grid.
outputFormat
Print a single integer to standard output (stdout) representing the area of the largest rectangle that contains only full boxes.## sample
4 5
1 0 1 0 0
1 0 1 1 1
1 1 1 1 1
1 0 0 1 0
6