跳到主要内容
图灵 OJTURING / ONLINE JUDGE

#F2223. Maximum Submatrix 2

    ID: 2229 传统题 2000ms 256MiB 尝试: 0 已通过: 0 难度: 4 上传者: 标签>数据结构动态规划模拟排序编程与模拟进阶难度共享题库Codeforces英文题面题目来源题面语言

Maximum Submatrix 2

题目描述

B. Maximum Submatrix 2
time limit per test
2 seconds
memory limit per test
512 megabytes
input
standard input
output
standard output

You are given a matrix consisting of digits zero and one, its size is n×m. You are allowed to rearrange its rows. What is the maximum area of the submatrix that only consists of ones and can be obtained in the given problem by the described operations?

Let's assume that the rows of matrix a are numbered from 1 to n from top to bottom and the columns are numbered from 1 to m from left to right. A matrix cell on the intersection of the i-th row and the j-th column can be represented as (i,j). Formally, a submatrix of matrix a is a group of four integers d,u,l,r (1≤dun;1≤lrm). We will assume that the submatrix contains cells (i,j) (diu;ljr). The area of the submatrix is the number of cells it contains.

Input

The first line contains two integers n and m (1≤n,m≤5000). Next n lines contain m characters each − matrix a. Matrix a only contains characters: "0" and "1". Note that the elements of the matrix follow without any spaces in the lines.

Output

Print a single integer − the area of the maximum obtained submatrix. If we cannot obtain a matrix of numbers one, print 0.

Examples
Input
1 1
1
Output
1
Input
2 2
10
11
Output
2
Input
4 3
100
011
000
101
Output
2

题目来源:fps-www.educg.net-codeforce-1-2833.xml.zip;FPS 共享题包,题包内第 1829 题。保留原作者与原赛事署名。