POJ 1050
来源:互联网 发布:编程培训中心哪里好 编辑:程序博客网 时间:2024/05/29 02:46
**
**
很满意的一份代码 无论是长短速度还是内存都应该入得了终神犇的法眼~
最小矩阵和裸题复杂度应该是n^3 吧
前缀和储存
枚举 i k
为第i行到第k行的和
即转化为求最大连续字段和
貌似说的不怎么明白啊…QAQ
#include <cstdio>const int maxn=110;int map[maxn][maxn];int main(){ int n,max=0; scanf("%d",&n); for(int i=1;i<=n;i++) { for(int j=1;j<=n;j++) { scanf("%d",&map[i][j]); map[i][j]+=map[i-1][j]; } for(int k=1;k<=i;k++) { int num=0,m=0; for(int j=1;j<=n;j++) { if(m>0)m+=map[i][j]-map[k-1][j]; else m=map[i][j]-map[k-1][j]; if(m>max)max=m; } } } printf("%d",max); return 0;}
0 0
- POJ 1050
- poj 1050
- POJ 1050
- POJ 1050
- poj 1050
- poj 1050
- POJ 1050
- poj 1050
- poj--1050
- poj 1050
- POJ 1050
- POJ 1050
- Poj 1050
- POJ 1050
- poj-1050
- poj 1050
- poj 1050
- POJ 1050
- sql server学习地址
- Cocos2d-x3.0模版容器详解之一:cocos2d::Vector<T>
- C++面试题整理汇总!!!
- 加速python,保护你的源代码
- JavaScript新增输入框
- POJ 1050
- 使用ftp传输文件到arm板
- Your password has expired. To log in you must change it using a cl...
- VO(DTO)模式在分层架构设计中是否需要的扯淡
- 企业如何选购适合的视频会议产品
- shell脚本 自定义传入参数选项
- WebMvcConfigurerAdapter的用法
- C++调用webservice
- IOS UIWebView与Javascript之间的交互