题目:click here

 #include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ll;
const int INF = 0x3f3f3f3f;
const int M = 2e2+; int n;
int a[M][M]; // a[i][j] 表示从[i][0]到[i][j]的和
int main() {
while( ~scanf("%d", &n ) ) {
memset( a, , sizeof(a) );
for( int i=; i<=n; i++ ) {
for( int j=; j<=n; j++ ) {
scanf("%d", &a[i][j] );
a[i][j] += a[i][j-];
}
}
int ret = -INF;
for( int i=; i<=n; i++ ) {
for( int j=; j<i; j++ ) {
int sum = ;
for( int h=; h<=n; h++ ) {
sum += a[h][i] - a[h][j];
ret = max( ret, sum );
if( sum < ) sum = ;
}
}
}
printf("%d\n", ret );
}
return ;
}

URAL 1146 Maximum Sum 最大子矩阵和的更多相关文章

  1. 最大子矩阵和 URAL 1146 Maximum Sum

    题目传送门 /* 最大子矩阵和:把二维降到一维,即把列压缩:然后看是否满足最大连续子序列: 好像之前做过,没印象了,看来做过的题目要经常看看:) */ #include <cstdio> ...

  2. ural 1146. Maximum Sum

    1146. Maximum Sum Time limit: 0.5 secondMemory limit: 64 MB Given a 2-dimensional array of positive ...

  3. ural 1146. Maximum Sum(动态规划)

    1146. Maximum Sum Time limit: 1.0 second Memory limit: 64 MB Given a 2-dimensional array of positive ...

  4. URAL 1146 Maximum Sum(最大子矩阵的和 DP)

    Maximum Sum 大意:给你一个n*n的矩阵,求最大的子矩阵的和是多少. 思路:最開始我想的是预处理矩阵,遍历子矩阵的端点,发现复杂度是O(n^4).就不知道该怎么办了.问了一下,是压缩矩阵,转 ...

  5. URAL 1146 Maximum Sum(DP)

    Given a 2-dimensional array of positive and negative integers, find the sub-rectangle with the large ...

  6. URAL 1146 Maximum Sum & HDU 1081 To The Max (DP)

    点我看题目 题意 : 给你一个n*n的矩阵,让你找一个子矩阵要求和最大. 思路 : 这个题都看了好多天了,一直不会做,今天娅楠美女给讲了,要转化成一维的,也就是说每一列存的是前几列的和,也就是说 0 ...

  7. Timus 1146. Maximum Sum

    1146. Maximum Sum Time limit: 0.5 secondMemory limit: 64 MB Given a 2-dimensional array of positive ...

  8. UVa 108 - Maximum Sum(最大连续子序列)

    题目来源:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=3&pa ...

  9. UVa 10827 - Maximum sum on a torus

    题目大意:UVa 108 - Maximum Sum的加强版,求最大子矩阵和,不过矩阵是可以循环的,矩阵到结尾时可以循环到开头.开始听纠结的,想着难道要分情况讨论吗?!就去网上搜,看到可以通过补全进行 ...

随机推荐

  1. 设置cmd的codepage的方法

    设置cmd的codepage的方法 有时候,我们的cmd.exe的codepage和字体等会变化,比如突然由中文变成英文的codepage(因为一些sh程序的干扰). 下面是修正方法: [HKEY_C ...

  2. issues about Facebook Login

    在学习The complete iOS 9 Developer Course - Build 18 Apps 中的Letture134-Facebook Login,需要整合(integrate)Pa ...

  3. 关于mysqli 连接数不能正确释放的解决方案

    /** * 析构函数 */ //解决重复链接的问题 private $db_handler = null; function __destruct() { Log::logWrite($this-&g ...

  4. delphi关于文件操作集锦

        关于文件操作集锦 取得该快捷方式的指向EXE关键词:快捷方式 LNK unit Unit1; interface usesWindows, Messages, SysUtils, Varian ...

  5. 2014年辛星Javascript解读第二节

    本小节我们解说一下Javascript的语法,尽管js语言很easy,它的语法也相对好学一些,可是不学总之还是不会的,因此,我们来一探到底把. ********凝视************* 1.我们 ...

  6. jQuery实现页面关键字搜索

    <style type="text/css"> .highlight { background-color:yellow; } </style> <s ...

  7. iOS:将NSDate转换为当前时区时间

     NSDate *date = [NSDate date]; NSTimeZone *zone = [NSTimeZone systemTimeZone]; NSInteger interval = ...

  8. 使用PHP实现用户登录和注册的功能

    登陆界面 login.php <form action="logincheck.php" method="post"> 用户名:<input ...

  9. Servlet运行过程详解

    比如,在浏览器地址栏输入http://ip:port/web01/hello step1,浏览器依据ip,port建立与servlet容器(容器同时也是一个简单的web服务器)之间的连接. step2 ...

  10. .net 更改时间格式

    /// <summary> /// 更改时间格式[HH:mm:ss]到[HHmmss] /// </summary> /// <param name="inpu ...