题目链接:http://poj.org/problem?id=1050

#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std; const int maxn = ;
const int INF = 0x3f3f3f; int dp[maxn];
int sum[maxn][maxn];
int ans; int main()
{
//freopen("E:\\acm\\input.txt","r",stdin);
int N;
cin>>N;
for(int i=;i<=N;i++) sum[][i] = sum[i][] = ;
for(int i=;i<=N;i++)
for(int j=;j<=N;j++){
int a;
scanf("%d",&a);
sum[i][j] = sum[i-][j] + a;
}
ans = -INF;
for(int i=;i<=N;i++)
for(int j=i;j<=N;j++){
memset(dp,,sizeof(dp));
for(int k=;k<=N;k++){
dp[k] = max(,dp[k-]) + sum[j][k] - sum[i][k];
ans = max(dp[k],ans);
}
}
printf("%d\n",ans);
}
//自己的做时候,一直想怎样写dp并表示出状态转移方程,但是就是怎么也想不出来,觉得不好表示。没办法看了别人的想法,马上反应过来。头脑僵化了啊!!!

poj 1050 To the Max (简单dp)的更多相关文章

  1. poj - 1050 - To the Max(dp)

    题意:一个N * N的矩阵,求子矩阵的最大和(N <= 100, -127 <= 矩阵元素 <= 127). 题目链接:http://poj.org/problem?id=1050 ...

  2. poj 1050 To the Max(线性dp)

    题目链接:http://poj.org/problem?id=1050 思路分析: 该题目为经典的最大子矩阵和问题,属于线性dp问题:最大子矩阵为最大连续子段和的推广情况,最大连续子段和为一维问题,而 ...

  3. POJ 1050 To the Max 枚举+dp

    大致题意: 求最大子矩阵和 分析: 一开始想复杂了,推出了一个状态方程:d[i][j]=max(d[i][j-1]+-,d[i-1][j]+-).写着写着发现上式省略的部分记录起来很麻烦. 后来发现n ...

  4. [poj]1050 To the Max dp

    Description Given a two-dimensional array of positive and negative integers, a sub-rectangle is any ...

  5. POJ 1050 To the Max 最大子矩阵和(二维的最大字段和)

    传送门: http://poj.org/problem?id=1050 To the Max Time Limit: 1000MS   Memory Limit: 10000K Total Submi ...

  6. poj 1050 To the Max(最大子矩阵之和)

    http://poj.org/problem?id=1050 我们已经知道求最大子段和的dp算法 参考here  也可参考编程之美有关最大子矩阵和部分. 然后将这个扩大到二维就是这道题.顺便说一下,有 ...

  7. poj 1050 To the Max 最大子矩阵和 经典dp

    To the Max   Description Given a two-dimensional array of positive and negative integers, a sub-rect ...

  8. poj 1050 To the Max(最大子矩阵之和,基础DP题)

    To the Max Time Limit: 1000MSMemory Limit: 10000K Total Submissions: 38573Accepted: 20350 Descriptio ...

  9. POJ 1050 To the Max 暴力,基础知识 难度:0

    http://poj.org/problem?id=1050 设sum[i][j]为从(1,1)到(i,j)的矩形中所有数字之和 首先处理出sum[i][j],此时左上角为(x1,y1),右下角为(x ...

随机推荐

  1. 【转】ASP.NET常用数据绑定控件优劣总结

    转自:http://www.cnblogs.com/Olive116/archive/2012/10/24/2736570.html ASP.NET常用数据绑定控件优劣总结   本文的初衷在于对Asp ...

  2. 【实习记】2014-08-18使用curl排错http头的content-length

        总结一,用curl排错Content-Length设置错误,误导了客户端. 访问/cgi-bin/txproj_list时,firebug显示总是不多不少15秒,调试其他问题时郁闷. fire ...

  3. Mac OS X 好用的软件包管理工具 Homebrew

    github地址:https://github.com/Homebrew/homebrew 安装方法:http://brew.sh/

  4. session cookie 相结合实现

    数据库配置文件 config.php <?php// config.php 数据库连接文件define('DB_HOST', 'localhost');define('DB_USER', 'ro ...

  5. 利用青瓷布局自定义加载的场景,而不是自己改写qici-loading

    加载界面如果全部通过自己手动布局不仅不美观,还很难控制.借用原生的场景切换加载效果,来实现我们游戏的加载效果. 没有做加载修改的原来的加载顺序:   黑乎乎界面->(游戏定制的加载)你的第一个场 ...

  6. word2007在试图打开文件时遇到错误解决方法

    当您尝试在 Microsoft Office Word 2007 中打开 .docx 文件时,该文件打不开.此外,您还会收到以下错误消息: Word 在试图打开文件时遇到错误.请尝试下列方法:* 检查 ...

  7. window.frameElement属性

    比如有一个iframe的src是xxx.htm frameElement的作用就是在xxx.htm中获得这个引用它的iframe objet 这样你就可以在xxx.htm改变iframe的大小,或是边 ...

  8. PYTHON开发--面向对象基础入门

    面向对象 一:面向对象初级 1.思考:首先在python中,以前我们以前用到的几乎都是函数式编程,但是有时候函数式编程其中代码重复利用率太高,我们往往会把这些重复代码写进一个函数日后去调用,所以呢,今 ...

  9. AngularJS: 自定义指令与控制器数据交互

    <!doctype html> <html> <head> <meta charset="utf-8"> <title> ...

  10. 2016030205 - ubuntu安装mysql

    ubuntu上安装mysql 1.检查ubuntu上是否已经安装mysql sudo netstat -tap | grep mysql 本机上没有安装mysql 2.安装mysql服务器端和客户端 ...