POJ1050【DP】
来源:互联网 发布:手机网络加速器破解版 编辑:程序博客网 时间:2024/05/17 07:52
题意:
求一个最大子矩阵和。
思路:
枚举行区间,然后求一个最大子序列和。
贴一发挫code…
#include <iostream>#include <cstdio>#include <string.h>#include <algorithm>using namespace std;typedef __int64 LL;const int N=1e2+10;int a[N][N];int dp[N];int main(){ int n; scanf("%d",&n); for(int i=1;i<=n;i++) for(int j=1;j<=n;j++) scanf("%d",&a[i][j]); int ans; ans=a[1][1]; for(int k=1;k<=n;k++) { for(int i=k;i<=n;i++) { for(int j=1;j<=n;j++) { if(i==k) dp[j]=a[i][j]; else dp[j]+=a[i][j]; } int tmax=0; for(int j=1;j<=n;j++) { if(tmax>0) tmax+=dp[j]; else tmax=dp[j]; if(tmax>ans) ans=tmax; } } } printf("%d\n",ans); return 0;}/*40 -2 -7 09 2 -6 2-4 1 -4 1-1 8 0 -2*/
0 0
- POJ1050 DP
- POJ1050【DP】
- [DP] POJ1050
- POJ1050 dp入门
- poj1050(DP)
- DP::Poj1050 To the max
- poj1050 To the Max (dp)
- POJ1050 TO THE MAX [DP]
- poj1050(dp最大子矩阵)
- poj1050 to the max (DP)
- poj1050(压缩矩阵)(dp)
- poj1050 To the Max dp
- poj1050 To the Max dp
- POJ1050
- poj1050
- POJ1050
- poj1050
- poj1050
- JFreeChart仪表图DialChartDemo2
- sql与oracle中有关case和decode的用法(行转列)及比较
- Eclipse中在项目右键菜单点击->Maven->Update Projects时,JDK总是切回 1.5
- Android Junit Test Process
- Oracle 12c RAC安装PSU
- POJ1050【DP】
- ORACLE 导出错误 EXP-00008: 遇到 Oracle 错误 904
- 华为OJ——数字颠倒
- VC++中Format函数详解
- Educational Codeforces Round 15 B. Powers of Two (数学)
- Java compiler level does not match the version of the installed Java project facet.
- yii2 controller behavior函数的beforeAction实现原理
- 190 git post-receive 钩子不能正常执行 git pull
- 红黑树元素的插入和删除