博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
poj 1050 To the Max
阅读量:6005 次
发布时间:2019-06-20

本文共 1701 字,大约阅读时间需要 5 分钟。

To the MaxTime Limit: 1000MS Memory Limit: 10000K

Total Submissions: 37431 Accepted: 19715
Description
Given a two-dimensional array of positive and negative integers, a sub-rectangle is any contiguous sub-array of size 1*1 or greater located within the whole array. The sum of a rectangle is the sum of all the elements in that rectangle. In this problem the sub-rectangle with the largest sum is referred to as the maximal sub-rectangle.
As an example, the maximal sub-rectangle of the array:
0 -2 -7 0
9 2 -6 2
-4 1 -4 1
-1 8 0 -2
is in the lower left corner:
9 2
-4 1
-1 8
and has a sum of 15.
Input
The input consists of an N * N array of integers. The input begins with a single positive integer N on a line by itself, indicating the size of the square two-dimensional array. This is followed by N^2 integers separated by whitespace (spaces and newlines). These are the N^2 integers of the array, presented in row-major order. That is, all numbers in the first row, left to right, then all numbers in the second row, left to right, etc. N may be as large as 100. The numbers in the array will be in the range [-127,127].
Output
Output the sum of the maximal sub-rectangle.
Sample Input
4
0 -2 -7 0 9 2 -6 2
-4 1 -4 1 -1
8 0 -2
Sample Output
15
Source
Greater New York 2001

//208K    16MS    C++    862B//二维dp,枚举全部矩形 #include
#include
int g[105][105];int dp[105];int main(void){ int n; while(scanf("%d",&n)!=EOF) { for(int i=0;i
tmax) tmax=t; } if(tmax>ans) ans=tmax; } } printf("%d\n",ans); } return 0;}

 

转载于:https://www.cnblogs.com/GO-NO-1/articles/3325231.html

你可能感兴趣的文章
下午最后的草坪
查看>>
Maven学习总结(七)——eclipse中使用Maven创建Web项目
查看>>
用PHP读取和编写XML DOM4
查看>>
1.部分(苹果)移动端的cookie不支持中文字符,2.从json字符串变为json对象时,只支持对象数组...
查看>>
vim配置及快捷键
查看>>
2018省赛赛第一次训练题解和ac代码
查看>>
[转载] win10进行端口转发
查看>>
利用JavaScript jQuery实现图片无限循环轮播(不借助于轮播插件)-----转载
查看>>
从零开始搭建vue项目 请求拦截器 响应拦截器
查看>>
HDU3257 Hello World!【打印图案+位运算】
查看>>
jquery 选择器
查看>>
The secret code
查看>>
Makefile 多目录自动编译
查看>>
学习笔记:Oracle dul数据挖掘 导出Oracle11G数据文件坏块中表中
查看>>
Linux 进程间通信(二) 管道
查看>>
深入浅出JQuery (二) 选择器
查看>>
CI框架 -- 驱动器
查看>>
FastMQ V0.2.0 stable版发布
查看>>
对象复制
查看>>
Mongodb内嵌数组的完全匹配查询
查看>>