hdu1081 To The Max
来源:互联网 发布:机明石墨电极编程视频 编辑:程序博客网 时间:2024/05/22 04:50
最大子矩阵和。。一个矩阵看成多个小的矩阵。。改了俩天。。真蛋疼
#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>using namespace std;#define INF -9999int const MAXN = 110;int a[MAXN][MAXN],dp[MAXN][MAXN];inline int Max(int a,int b){ return a>b?a:b;}int main(){ int n; while(~scanf("%d",&n)){ memset(a,0,sizeof(a)); memset(dp,0,sizeof(dp)); for(int i = 1;i <= n;i++){ for(int j = 1;j <= n;j++){ scanf("%d",&a[i][j]); } } for(int i = 1;i <= n;i++){ for(int j = 1;j <= n;j++){ dp[i][j] += dp[i][j - 1] + a[i][j]; } } int m = INF; for(int i = 1;i <= n;i++){ for(int j = i;j <= n;j++){ int sum = 0,s = 0; for(int k = 1;k <= n;k++){ if(sum < 0) sum = 0; sum += dp[k][j] - dp[k][i - 1]; s = Max(s,sum); } m = Max(s,m); } } printf("%d\n",m); } return 0;}
0 0
- To the max(hdu1081)
- HDU1081--To The Max
- hdu1081-To The Max
- hdu1081-To The Max
- HDU1081 To The Max
- hdu1081 To The Max
- hdu1081 To The Max
- hdu1081 To The Max
- hdu1081 To the Max
- hdu1081 To The Max (dp)
- HDU1081 To The Max (DP)
- POJ1050&HDU1081-To the Max
- hdu1081——To The Max
- hdu1081 ||poj 1050 To the Max
- hdu1081 To The Max 「dp」
- 【最大子矩阵和】HDU1081-To The Max
- hdu1081 To The Max(动态规划-最大子矩阵)
- hdu1081 To The Max--DP(最大子矩阵和)
- chattr、lsattr linux的隐藏文件属性查看的命令
- android电话拨号器
- POJ 2528 Mayor's posters.
- android笔记
- 网络编程之TCP/UDP及其流程比较
- hdu1081 To The Max
- No matching provisioning profiles found
- UVA 11181 - Probability|Given
- 开发中常用的第三方工具(持续跟新,依时间而定)
- JDBC 增删改查工具类 和测试类
- vim 重新打开无法回到上次关闭位置
- Android Tween Animation
- BZOJ 1221 软件开发(网络流24题之餐巾规划)
- Mysql字符串函数FIND_IN_SET()的两点用法