Matrix Swapping II

Time Limit : 9000/3000ms (Java/Other)   Memory Limit : 32768/32768K (Java/Other)
Total Submission(s) : 12   Accepted Submission(s) : 8
Font: Times New Roman | Verdana | Georgia
Font Size: ← →
Problem Description

Given an N * M matrix with each entry equal to 0 or 1. We can find some rectangles in the matrix whose entries are all 1, and we define the maximum area of such rectangle as this matrix’s goodness.
We can swap any two columns any times, and we are to make the goodness of the matrix as large as possible.

Input

There are several test cases in the input. The first line of each test case contains two integers N and M (1 ≤ N,M ≤ 1000). Then N lines follow, each contains M numbers (0 or 1), indicating the N * M matrix

Output

Output one line for each test case, indicating the maximum possible goodness.

Sample Input
3 4
1011
1001
0001
3 4
1010
1001
0001
Sample Output
4
2
分析:对每一行进行处理然后再叠加,到每一行用sum[j]记下到这一行有多少个1

例如:

1 0 1 1 sum[j]的记录就是: 1 0 1 1

1 0 0 1                             2 0 0 2

0 0 0 1                             0 0 0 3

然后对num[j]从大到小排一下,求出读取到当前行能够得到的最大面积。

也就是最右边放着最多的1,依次类推。那么当前最大的面积就是 MAX(max,sum[j]*(j+1))了

转载于:https://www.cnblogs.com/lzmfywz/articles/2356888.html

HDU OJ Matrix Swapping II相关推荐

  1. HDU 2830 Matrix Swapping II

    暴力枚举+DP预处理. 可以枚举矩形底边是哪一行,枚举到一行的时候,计算以该行为底边,最大矩形面积是多少. #include<cstdio> #include<cstring> ...

  2. HDU OJ 动态规划46题解析

    Robberies http://acm.hdu.edu.cn/showproblem.php?pid=2955  背包;第一次做的时候把概率当做背包(放大100000倍化为整数):在此范围内最多能抢 ...

  3. hdu A + B Problem II(大数相加,数组实现)

    hdu A + B Problem II(大数相加,数组实现) 题目走起 注意最后一个case 不需要换行 下面代码 #include<stdio.h> #include<strin ...

  4. hdu 6149 Valley Numer II(01背包套状压dp)

    题目链接:hdu 6149 Valley Numer II 题意: 给你N个点,有k个为高点,其他为低点,现在这N个点有m条边,问你最多能组成多少个两个高点一个低点,低点和两个高点都有边相连这样的状态 ...

  5. [C#] 逆袭——自制日刷千题的AC自动机攻克HDU OJ

    前言 做过杭电.浙大或是北大等ACM题库的人一定对"刷题"不陌生,以杭电OJ为例:首先打开首页(http://acm.hdu.edu.cn/),然后登陆,接着找到"Onl ...

  6. HDU - 2639 Bone Collector II

    HDU - 2639 Bone Collector II dp之难,难于上青天. The title of this problem is familiar,isn't it?yeah,if you ...

  7. LeetCode:Spiral Matrix I II

    Spiral Matrix Given a matrix of m x n elements (m rows, n columns), return all elements of the matri ...

  8. hdu 1023 Train Problem II

    题目连接 http://acm.hdu.edu.cn/showproblem.php?pid=1212 Train Problem II Description As we all know the ...

  9. Spiral Matrix I II

    Spiral Matrix I Given an integer n, generate a square matrix filled with elements from 1 to n^2 in s ...

最新文章

  1. DPDK — App 的 Makefile 解析
  2. sql server:删除表数据,标识列Id从1开始
  3. 实战渗透-Shiro反序列化漏洞实例
  4. Android6 0权限机制(一):介绍
  5. 【ArcGIS风暴】基于ArcGIS空间分析功能研究渭河流域镇驻地空间分布格局
  6. Spring-boot IDEA使用注解@ConfigurationProperties时报错解决
  7. 将社交登录添加到Spring MVC Web应用程序:配置
  8. IT公司刻板印象合集:程序员都秃头,商务个个是人精
  9. 最新数据:中国网民超10亿,中老年群体增速最快
  10. oracle 10g RAC app VIP ,ONS,GSD,ASM,OCR,VOTE名称及代表的涵义。
  11. Maven学习总结(17)——深入理解maven灵活的构建
  12. 听说你想进玩TikTok?
  13. 云架构化-设计理念参考
  14. 【转载】基于Redis实现分布式锁
  15. 根据已有的WSDL文件进行WebService服务开发和部署
  16. 【光学】基于matlab GUI(杨氏双缝+劈尖)干涉+(单缝+多缝+圆孔+矩孔)衍射仿真【含Matlab源码 878期】
  17. 戴尔r410服务器raid装系统,Dell R410 Raid磁盘阵列驱动
  18. 众数和中位数的应用题_什么是众数和中位数
  19. 如何运营一个软件微社区
  20. CTF基础知识-Web

热门文章

  1. 4月22日(牛马不对嘴)
  2. T-SQL常用字符串函数
  3. 从NT向solaris 8移植C/C++应用
  4. pain point
  5. why the ebitda and ebit differ so much for netflix?
  6. technology and business combination point
  7. less than 50000 rmb convertible car
  8. 2018年香港私隐公署接129宗资料外泄通报 创新高
  9. Form组件,用ajax发送到后台需要的注意事项
  10. Linux操作系统安装---centos6.7安装图文实例详解(完整版)